From c5f92efdd19464b876e56750f85a6d8ba4d7b558 Mon Sep 17 00:00:00 2001 From: Caio Carrara Date: Wed, 11 May 2016 16:24:46 -0300 Subject: Remove dispatcher references from service Since we're not using dispatcher anymore, it doesn't make sense to keep dispatcher references and program flows that depend on it. For example, it doesn't make sense keep the flag --organization-mode, so it was removed as well. --- service/test/functional/features/environment.py | 1 - service/test/unit/config/test_credentials.py | 30 ------------------------- service/test/unit/test_welcome_mail.py | 18 +++++++-------- 3 files changed, 9 insertions(+), 40 deletions(-) delete mode 100644 service/test/unit/config/test_credentials.py (limited to 'service/test') diff --git a/service/test/functional/features/environment.py b/service/test/functional/features/environment.py index 2c07faf3..41f2c8c7 100644 --- a/service/test/functional/features/environment.py +++ b/service/test/functional/features/environment.py @@ -22,7 +22,6 @@ from twisted.internet import defer from pixelated.application import UserAgentMode from pixelated.config.site import PixelatedSite -from test.support.dispatcher.proxy import Proxy from test.support.integration import AppTestClient from selenium import webdriver diff --git a/service/test/unit/config/test_credentials.py b/service/test/unit/config/test_credentials.py deleted file mode 100644 index 6c25c5bf..00000000 --- a/service/test/unit/config/test_credentials.py +++ /dev/null @@ -1,30 +0,0 @@ -import json -import unittest -import sys -from mockito import mock, when -from pixelated.config import arguments -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 = arguments.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 diff --git a/service/test/unit/test_welcome_mail.py b/service/test/unit/test_welcome_mail.py index 829740d3..fe2b3005 100644 --- a/service/test/unit/test_welcome_mail.py +++ b/service/test/unit/test_welcome_mail.py @@ -15,6 +15,7 @@ # along with Pixelated. If not, see . import os +import re import unittest from mockito import verify, mock from mockito.matchers import Matcher @@ -61,13 +62,12 @@ class WelcomeMailCapture(Matcher): def _format(self, mail): splitter = '\n' - arr = mail.split(splitter) - arr = self._remove_variable_value(arr) + mail_lines = mail.split(splitter) + mail_lines = self._remove_boundaries(mail_lines) + return splitter.join(mail_lines) - return splitter.join(arr) - - def _remove_variable_value(self, arr): - arr.pop(0) - arr.pop(6) - arr.pop(44) - return arr + def _remove_boundaries(self, mail_lines): + # boundary example --===============5031169581469213585==-- + boundary_regex = re.compile("^(.*)(\={15})(\w*)(\={2})(.*)$") + boundaries = filter(boundary_regex.match, mail_lines) + return [line for line in mail_lines if line not in boundaries] -- cgit v1.2.3