@@ -30,7 +30,7 @@ def _resource(self) -> Generator[None, None, None]:
30
30
# Ensure that allow_exit_as_root has the default value
31
31
agent .options .allow_exit_as_root = False
32
32
33
- async def publish_message (self ) -> None :
33
+ async def publish_message (self , params_combination : str = "both_args" ) -> None :
34
34
# Perform connection
35
35
connection = await connect ()
36
36
@@ -46,11 +46,22 @@ async def publish_message(self) -> None:
46
46
exchange = await channel .declare_exchange ("test.exchange" )
47
47
await queue .bind (exchange , routing_key = queue_name )
48
48
49
+ message = Message (f"Hello { queue_name } " .encode ())
50
+
51
+ args = ()
52
+ kwargs = {}
53
+
54
+ if params_combination == "both_kwargs" :
55
+ kwargs = {"message" : message , "routing_key" : queue_name }
56
+ elif params_combination == "arg_kwarg" :
57
+ args = (message ,)
58
+ kwargs = {"routing_key" : queue_name }
59
+ else :
60
+ # params_combination == "both_args"
61
+ args = (message , queue_name )
62
+
49
63
# Sending the message
50
- await exchange .publish (
51
- Message (f"Hello { queue_name } " .encode ()),
52
- routing_key = queue_name ,
53
- )
64
+ await exchange .publish (* args , ** kwargs )
54
65
55
66
async def delete_queue (self ) -> None :
56
67
connection = await connect ()
@@ -75,9 +86,13 @@ async def consume_message(self, connect_method) -> None:
75
86
if queue .name in message .body .decode ():
76
87
break
77
88
78
- def test_basic_publish (self ) -> None :
89
+ @pytest .mark .parametrize (
90
+ "params_combination" ,
91
+ ["both_args" , "both_kwargs" , "arg_kwarg" ],
92
+ )
93
+ def test_basic_publish (self , params_combination ) -> None :
79
94
with tracer .start_as_current_span ("test" ):
80
- self .loop .run_until_complete (self .publish_message ())
95
+ self .loop .run_until_complete (self .publish_message (params_combination ))
81
96
82
97
spans = self .recorder .queued_spans ()
83
98
assert len (spans ) == 2
0 commit comments