@@ -14,17 +14,17 @@ def mock_client() -> Mock:
14
14
15
15
16
16
@pytest .fixture
17
- def command_sender (mock_client : Mock ) -> StreamDeckCommandSender :
17
+ def command_sender (mock_client : Mock , plugin_registration_uuid : str ) -> StreamDeckCommandSender :
18
18
"""Fixture to provide an instance of StreamDeckCommandSender with a mocked client."""
19
- return StreamDeckCommandSender (client = mock_client )
19
+ return StreamDeckCommandSender (client = mock_client , plugin_registration_uuid = plugin_registration_uuid )
20
20
21
21
22
22
@pytest .mark .parametrize (
23
23
("method_name" , "context" , "extra_args" , "expected_event" , "expected_payload" ),
24
24
[
25
25
(
26
26
"get_global_settings" ,
27
- "fake_context" ,
27
+ None , # get_global_settings uses the command_sender's own plugin_registration_uuid attribute as the context.
28
28
{},
29
29
"getGlobalSettings" ,
30
30
{}
@@ -115,7 +115,7 @@ def command_sender(mock_client: Mock) -> StreamDeckCommandSender:
115
115
),
116
116
(
117
117
"set_global_settings" ,
118
- "fake_context" ,
118
+ None , # set_global_settings uses the command_sender's own plugin_registration_uuid attribute as the context.
119
119
{"payload" : {"key" : "value" }},
120
120
"setGlobalSettings" ,
121
121
{"payload" : {"key" : "value" }},
@@ -147,7 +147,7 @@ def test_command_sender_methods(
147
147
command_sender : StreamDeckCommandSender ,
148
148
mock_client : Mock ,
149
149
method_name : str ,
150
- context : str ,
150
+ context : str | None ,
151
151
extra_args : dict ,
152
152
expected_event : str ,
153
153
expected_payload : dict ,
@@ -157,14 +157,17 @@ def test_command_sender_methods(
157
157
assert hasattr (command_sender , method_name )
158
158
159
159
method = getattr (command_sender , method_name )
160
- method (context , ** extra_args )
160
+ if context is not None :
161
+ method (context , ** extra_args )
162
+ else :
163
+ method (** extra_args )
161
164
162
165
# Build the expected data structure to send through the WebSocket
163
166
expected_data = {
164
- "context" : context ,
167
+ "context" : context or command_sender . _plugin_registration_uuid ,
165
168
"event" : expected_event ,
166
169
** expected_payload ,
167
170
}
168
171
169
172
# Assert that the client's send_event method was called with the expected data
170
- mock_client .send_event .assert_called_once_with (expected_data )
173
+ mock_client .send_event .assert_called_once_with (expected_data )
0 commit comments