summaryrefslogtreecommitdiff
path: root/service/test
diff options
context:
space:
mode:
authorFolker Bernitt <fbernitt@thoughtworks.com>2014-10-02 10:59:34 +0200
committerFolker Bernitt <fbernitt@thoughtworks.com>2014-10-02 10:59:34 +0200
commit9b48cf1a85ced79a22a8668e2da3a84947c4e97c (patch)
treed49f5bce93b4a54ea9f983f725ffe70ccf8ca6f2 /service/test
parenteffec78faacc4def3cd1f1f7fbedf79eaeb824f5 (diff)
Added config file command line parameter to user agent.
Diffstat (limited to 'service/test')
-rw-r--r--service/test/user_agent_test.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/service/test/user_agent_test.py b/service/test/user_agent_test.py
index d0cfc5a9..fea8393a 100644
--- a/service/test/user_agent_test.py
+++ b/service/test/user_agent_test.py
@@ -19,9 +19,13 @@ import pixelated.user_agent
from pixelated.adapter.pixelated_mail import PixelatedMail
from pixelated.adapter.pixelated_mail import InputMail
from mockito import *
+import crochet
+import pixelated.reactor_manager as reactor_manager
import test.adapter.test_helper as test_helper
import json
import pixelated.adapter.pixelated_mail
+import sys
+import os
class UserAgentTest(unittest.TestCase):
@@ -35,6 +39,9 @@ class UserAgentTest(unittest.TestCase):
self.input_mail = None
pixelated.adapter.pixelated_mail.input_mail_from_dict = lambda x: self.input_mail
+ def tearDown(self):
+ unstub()
+
def test_create_or_send_draft_should_create_draft_if_mail_has_no_ident(self):
self.input_mail = self.draft()
@@ -60,3 +67,33 @@ class UserAgentTest(unittest.TestCase):
def draft(self):
return test_helper.input_mail()
+
+ def test_that_default_config_file_is_home_dot_pixelated(self):
+ orig_config = pixelated.user_agent.app.config
+ try:
+ when(crochet).setup().thenReturn(None)
+ when(reactor_manager).start_reactor().thenReturn(None)
+ when(pixelated.user_agent).start_user_agent().thenReturn(None)
+ pixelated.user_agent.app.config = mock()
+
+ sys.argv = ['/tmp/does_not_exist']
+ pixelated.user_agent.setup()
+
+ verify(pixelated.user_agent.app.config).from_pyfile(os.path.join(os.environ['HOME'], '.pixelated'))
+ finally:
+ pixelated.user_agent.app.config = orig_config
+
+ def test_that_config_file_can_be_specified_on_command_line(self):
+ orig_config = pixelated.user_agent.app.config
+ try:
+ when(crochet).setup().thenReturn(None)
+ when(reactor_manager).start_reactor().thenReturn(None)
+ when(pixelated.user_agent).start_user_agent().thenReturn(None)
+ pixelated.user_agent.app.config = mock()
+
+ sys.argv = ['/tmp/does_not_exist', '--config', '/tmp/some/config/file']
+ pixelated.user_agent.setup()
+
+ verify(pixelated.user_agent.app.config).from_pyfile('/tmp/some/config/file')
+ finally:
+ pixelated.user_agent.app.config = orig_config