From 30ab7258392ebb884ca835ec32000275c61c65d0 Mon Sep 17 00:00:00 2001 From: Bruno Wagner Date: Mon, 27 Oct 2014 18:05:02 +0100 Subject: Errors out if pipe file doesn't exist --- service/test/unit/runserver_test.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'service/test/unit/runserver_test.py') diff --git a/service/test/unit/runserver_test.py b/service/test/unit/runserver_test.py index 80cbf543..57e211c9 100644 --- a/service/test/unit/runserver_test.py +++ b/service/test/unit/runserver_test.py @@ -16,21 +16,24 @@ import unittest import sys +import os +import thread import pixelated.runserver from mockito import * import pixelated.config.reactor_manager as reactor_manager -import pixelated.adapter.mail import pixelated.config.app_factory as app_factory class RunserverTest(unittest.TestCase): + def setUp(self): + when(reactor_manager).start_reactor().thenReturn(None) + when(app_factory).create_app().thenReturn(None) + def test_that_config_file_can_be_specified_on_command_line(self): orig_config = pixelated.runserver.app.config try: - when(reactor_manager).start_reactor().thenReturn(None) - when(app_factory).create_app().thenReturn(None) pixelated.runserver.app.config = mock(dict) pixelated.runserver.app.config.__setitem__ = mock() @@ -40,3 +43,19 @@ class RunserverTest(unittest.TestCase): verify(pixelated.runserver.app.config).from_pyfile('/tmp/some/config/file') finally: pixelated.runserver.app.config = orig_config + + def test_that_organization_switch_reads_the_credentials_from_pipe(self): + fifo_path = '/tmp/credentials-pipe' + if os.path.exists(fifo_path): + os.remove(fifo_path) + test_fifo = os.mkfifo('/tmp/credentials-pipe') + thread.start_new_thread(self.spin_up_fifo, (fifo_path,)) + sys.argv = ['tmp/does_not_exist', '--dispatcher'] + pixelated.runserver.credentials_pipe = fifo_path + pixelated.runserver.setup() + + def spin_up_fifo(self, test_fifo): + with open(test_fifo, 'w') as fifo: + fifo.write('test_provider') + fifo.write('test_user') + fifo.write('test_password') -- cgit v1.2.3