From f10f59204fc8e6217d1e787e2a20a6c5a0a5b4ba Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Mon, 8 Apr 2013 16:37:03 +0100 Subject: [PATCH 1/4] support python setup.py test --- serve_tests.py | 29 ----------------------------- setup.py | 1 + socketIO_client/tests.py | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 29 deletions(-) delete mode 100755 serve_tests.py diff --git a/serve_tests.py b/serve_tests.py deleted file mode 100755 index 47c946a..0000000 --- a/serve_tests.py +++ /dev/null @@ -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() diff --git a/setup.py b/setup.py index 2651b7a..03141e4 100755 --- a/setup.py +++ b/setup.py @@ -26,6 +26,7 @@ setup( 'anyjson', 'websocket-client', ], + test_suite="nose.collector", packages=find_packages(), include_package_data=True, zip_safe=True) diff --git a/socketIO_client/tests.py b/socketIO_client/tests.py index a85c48e..96e5863 100644 --- a/socketIO_client/tests.py +++ b/socketIO_client/tests.py @@ -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 From f1d0a49fb3999bf39faf6552c47f7b4fe8dcb5f9 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Mon, 8 Apr 2013 16:39:37 +0100 Subject: [PATCH 2/4] add travis configuration --- .travis.yml | 11 +++++++++++ requirements.txt | 7 +++++++ 2 files changed, 18 insertions(+) create mode 100644 .travis.yml create mode 100644 requirements.txt diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..0090a78 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: python +python: + - 2.6 + - 2.7 + - 3.3 +matrix: + allow_failures: + - python: 3.3 +install: + - pip install -r requirements.txt --use-mirrors +script: python setup.py test diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..5393f02 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,7 @@ +#Install +anyjson +websocket-client +#Test +nose +nose-cov +gevent-socketio From b9f7bed8e94d3e80933b131ef4595e17b1e36142 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Mon, 8 Apr 2013 16:46:51 +0100 Subject: [PATCH 3/4] add missing requirements --- .travis.yml | 1 + requirements.txt | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 0090a78..96f83ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,5 +7,6 @@ matrix: allow_failures: - python: 3.3 install: + - sudo apt-get build-dep -qq python-gevent - pip install -r requirements.txt --use-mirrors script: python setup.py test diff --git a/requirements.txt b/requirements.txt index 5393f02..296a9a8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,5 @@ websocket-client nose nose-cov gevent-socketio +multiprocessing + From 2d0f636b5d23f1712aff09c687471fb6c812ca08 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Mon, 8 Apr 2013 17:04:09 +0100 Subject: [PATCH 4/4] multiprocessing is a standard lib for 2.6+ --- requirements.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 296a9a8..5393f02 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,5 +5,3 @@ websocket-client nose nose-cov gevent-socketio -multiprocessing -