Browse Source

Do not allow event names with hyphens in them

Fixes #36
pull/41/head
Miguel Grinberg 9 years ago
parent
commit
a6838a233d
  1. 2
      socketio/server.py
  2. 4
      tests/test_server.py

2
socketio/server.py

@ -138,6 +138,8 @@ class Server(object):
client's acknowledgement callback function if it exists. The
``'disconnect'`` handler does not take a second argument.
"""
if '-' in event:
raise ValueError('event names cannot contain hypens')
namespace = namespace or '/'
def set_handler(handler):

4
tests/test_server.py

@ -45,6 +45,10 @@ class TestServer(unittest.TestCase):
self.assertEqual(s.handlers['/']['disconnect'], bar)
self.assertEqual(s.handlers['/foo']['disconnect'], bar)
def test_on_bad_event_name(self, eio):
s = server.Server()
self.assertRaises(ValueError, s.on, 'two-words')
def test_emit(self, eio):
mgr = mock.MagicMock()
s = server.Server(client_manager=mgr)

Loading…
Cancel
Save