From 7a8e9cc142ad368434031e4e008b40281d68150b Mon Sep 17 00:00:00 2001 From: Bruno Wagner Date: Thu, 4 Jun 2015 19:11:46 -0300 Subject: Config dispatcher and config_ua are now in credentials --- service/test/unit/config/test_credentials.py | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 service/test/unit/config/test_credentials.py (limited to 'service/test/unit/config/test_credentials.py') diff --git a/service/test/unit/config/test_credentials.py b/service/test/unit/config/test_credentials.py new file mode 100644 index 00000000..61cfac53 --- /dev/null +++ b/service/test/unit/config/test_credentials.py @@ -0,0 +1,30 @@ +import json +import unittest +import sys +from mockito import mock, when +from pixelated.config.args import parse_user_agent_args +from pixelated.config import credentials + + +class TestReadCredentials(unittest.TestCase): + + def setUp(self): + self.test_data = {'leap_provider_hostname': 'test_provider', 'user': 'test_user', 'password': 'test_password'} + + def test_organization_mode_reads_credentials_from_stdin(self): + data = json.dumps({'leap_provider_hostname': 'test_provider', 'user': 'test_user', 'password': 'test_password'}) + orig_stdin = sys.stdin + sys.stdin = mock() + when(sys.stdin).read().thenReturn(data) + + try: + sys.argv = ['tmp/does_not_exist', '--organization-mode'] + args = parse_user_agent_args() + + provider, user, password = credentials.read(args.organization_mode, 'not_used') + + self.assertEquals('test_provider', provider) + self.assertEquals('test_user', user) + self.assertEquals('test_password', password) + finally: + sys.stdin = orig_stdin -- cgit v1.2.3