@@ -194,6 +194,7 @@ def test_emit_two_arguments(self):
194194
195195 def test_emit_namespace (self ):
196196 c = asyncio_client .AsyncClient ()
197+ c .namespaces = ['/foo' ]
197198 c ._send_packet = AsyncMock ()
198199 _run (c .emit ('foo' , namespace = '/foo' ))
199200 expected_packet = packet .Packet (packet .EVENT , namespace = '/foo' ,
@@ -202,6 +203,12 @@ def test_emit_namespace(self):
202203 self .assertEqual (c ._send_packet .mock .call_args_list [0 ][0 ][0 ].encode (),
203204 expected_packet .encode ())
204205
206+ def test_emit_unknown_namespace (self ):
207+ c = asyncio_client .AsyncClient ()
208+ c .namespaces = ['/foo' ]
209+ self .assertRaises (exceptions .BadNamespaceError , _run ,
210+ c .emit ('foo' , namespace = '/bar' ))
211+
205212 def test_emit_with_callback (self ):
206213 c = asyncio_client .AsyncClient ()
207214 c ._send_packet = AsyncMock ()
@@ -216,6 +223,7 @@ def test_emit_with_callback(self):
216223
217224 def test_emit_namespace_with_callback (self ):
218225 c = asyncio_client .AsyncClient ()
226+ c .namespaces = ['/foo' ]
219227 c ._send_packet = AsyncMock ()
220228 c ._generate_ack_id = mock .MagicMock (return_value = 123 )
221229 _run (c .emit ('foo' , namespace = '/foo' , callback = 'cb' ))
0 commit comments