summaryrefslogtreecommitdiff
path: root/service/test
diff options
context:
space:
mode:
authorFolker Bernitt <fbernitt@thoughtworks.com>2014-11-10 14:51:43 +0100
committerFolker Bernitt <fbernitt@thoughtworks.com>2014-11-10 14:51:43 +0100
commite08bfa5ed89aefeb508b1bbae76bbf2a342f85a1 (patch)
tree8eba47fc7dd95a77f85841d435be38833d300f96 /service/test
parent5c9aa9aff7fed5feddc58845c72607caa7feb76c (diff)
Pass configured port number to reactor.
Diffstat (limited to 'service/test')
-rw-r--r--service/test/unit/config/app_factory_test.py15
-rw-r--r--service/test/unit/runserver_test.py13
2 files changed, 28 insertions, 0 deletions
diff --git a/service/test/unit/config/app_factory_test.py b/service/test/unit/config/app_factory_test.py
new file mode 100644
index 00000000..5adf3722
--- /dev/null
+++ b/service/test/unit/config/app_factory_test.py
@@ -0,0 +1,15 @@
+import unittest
+from mock import patch, MagicMock, ANY
+
+from pixelated.config.app_factory import create_app
+
+
+class AppFactoryTest(unittest.TestCase):
+
+ @patch('pixelated.config.app_factory.reactor')
+ def test_that_create_app_binds_to_port(self, reactor_mock):
+ app_mock = MagicMock()
+
+ create_app(app_mock, '127.0.0.1', 12345)
+
+ reactor_mock.listenTCP.assert_called_once_with(12345, ANY, interface='127.0.0.1')
diff --git a/service/test/unit/runserver_test.py b/service/test/unit/runserver_test.py
index e3cd8439..51ee899c 100644
--- a/service/test/unit/runserver_test.py
+++ b/service/test/unit/runserver_test.py
@@ -20,6 +20,7 @@ import os
import thread
import json
+import pixelated.config.app_factory
import pixelated.runserver
from mockito import *
import pixelated.config.app_factory as app_factory
@@ -32,6 +33,9 @@ class RunserverTest(unittest.TestCase):
events_server.ensure_server = lambda port=None: None
when(app_factory).create_app().thenReturn(None)
+ def tearDown(self):
+ unstub()
+
def test_that_config_file_can_be_specified_on_command_line(self):
self.config_file_loaded = None
@@ -55,6 +59,15 @@ class RunserverTest(unittest.TestCase):
sys.argv = ['tmp/does_not_exist', '--dispatcher', fifo_path]
pixelated.runserver.setup()
+ def test_start_services_provides_port(self):
+ bind_address = '127.0.0.1'
+ bind_port = 12345
+ when(app_factory).create_app(any(), bind_address, bind_port).thenReturn(None)
+
+ pixelated.runserver.start_services(bind_address, bind_port)
+
+ verify(app_factory).create_app(any(), bind_address, bind_port)
+
def spin_up_fifo(self, test_fifo):
with open(test_fifo, 'w') as fifo:
fifo.write(json.dumps({'leap_provider_hostname': 'test_provider', 'user': 'test_user', 'password': 'test_password'}))