support python setup.py test

This commit is contained in:
Thomas Grainger 2013-04-08 16:37:03 +01:00
commit f10f59204f
3 changed files with 41 additions and 29 deletions

View file

@ -1,29 +0,0 @@
'Launch this server in another terminal window before running tests'
from socketio import socketio_manage
from socketio.namespace import BaseNamespace
from socketio.server import SocketIOServer
class Namespace(BaseNamespace):
def on_aaa(self, *args):
self.socket.send_packet(dict(
type='event',
name='ddd',
args=args,
endpoint=self.ns_name))
class Application(object):
def __call__(self, environ, start_response):
socketio_manage(environ, {
'': Namespace,
'/chat': Namespace,
'/news': Namespace,
})
if __name__ == '__main__':
socketIOServer = SocketIOServer(('0.0.0.0', 8000), Application())
socketIOServer.serve_forever()

View file

@ -26,6 +26,7 @@ setup(
'anyjson',
'websocket-client',
],
test_suite="nose.collector",
packages=find_packages(),
include_package_data=True,
zip_safe=True)

View file

@ -3,6 +3,46 @@ from time import sleep
from unittest import TestCase
from socketio import socketio_manage
from socketio.namespace import BaseNamespace as SIOBaseNameSpace
from socketio.server import SocketIOServer
from multiprocessing import Process
class SIONamespace(SIOBaseNameSpace):
def on_aaa(self, *args):
self.socket.send_packet(dict(
type='event',
name='ddd',
args=args,
endpoint=self.ns_name))
class Application(object):
def __call__(self, environ, start_response):
socketio_manage(environ, {
'': SIONamespace,
'/chat': SIONamespace,
'/news': SIONamespace,
})
socketIOServer = SocketIOServer(('0.0.0.0', 8000), Application())
p = Process(target=socketIOServer.serve_forever)
def setup_module(module):
p.start()
def teardown_module(module):
p.terminate()
PAYLOAD = {'bbb': 'ccc'}
ON_RESPONSE_CALLED = False