Permalink
Browse files

Tests a bit better. Still not all there.

  • Loading branch information...
1 parent 5e1ede1 commit 62ee106d94f2dd6fd94d1a3e901baa4d86ba8b25 @philipn philipn committed Apr 12, 2012
Showing with 13 additions and 7 deletions.
  1. +13 −7 tests/test_namespace.py
View
@@ -1,21 +1,28 @@
from unittest import TestCase, main
from socketio.namespace import BaseNamespace
+from socketio.virtsocket import Socket
-class MockSocket(object):
+class MockSocketIOServer(object):
+ """Mock a SocketIO server"""
+ def __init__(self, *args, **kwargs):
+ self.sockets = {}
- def __init__(self, environ={}):
- self.environ = environ
+ def get_socket(self, socket_id=''):
+ return self.sockets.get(socket_id)
+
+
+class MockSocket(Socket):
+ pass
- def error(self, error_name, error_msg, endpoint, msg_id, quiet=False):
- return (error_name, error_msg, endpoint, msg_id)
class TestBaseNamespace(TestCase):
def setUp(self):
+ server = MockSocketIOServer()
self.environ = {}
- self.environ['socketio'] = MockSocket()
+ self.environ['socketio'] = MockSocket(server)
self.ns = BaseNamespace(self.environ, '/woot')
def test_process_packet_disconnect(self):
@@ -84,7 +91,6 @@ def test_process_packet_json(self):
def test_process_packet_event(self):
"""processing an event packet """
-
pkt = {'type': 'event',
'name': 'woot',
'endpoint': '',

0 comments on commit 62ee106

Please sign in to comment.