forked from Bogdanp/dramatiq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
message: add namedtuple methods for backwards-compat
Thanks to @jurrian for identifying the issue in Bogdanp/django_dramatiq#143
- Loading branch information
Showing
2 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import dramatiq | ||
|
||
|
||
def test_messages_have_namedtuple_methods(stub_broker): | ||
@dramatiq.actor | ||
def add(x, y): | ||
return x + y | ||
|
||
msg1 = add.message(1, 2) | ||
assert msg1.asdict() == msg1._asdict() | ||
|
||
assert msg1._field_defaults == {} | ||
assert msg1._fields == ( | ||
"queue_name", | ||
"actor_name", | ||
"args", | ||
"kwargs", | ||
"options", | ||
"message_id", | ||
"message_timestamp", | ||
) | ||
|
||
msg2 = msg1._replace(queue_name="example") | ||
assert msg2._asdict()["queue_name"] == "example" |