diff --git a/src/postorius/tests/__init__.py b/src/postorius/tests/__init__.py index 2374145..e69de29 100644 --- a/src/postorius/tests/__init__.py +++ b/src/postorius/tests/__init__.py @@ -1,37 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2012-2016 by the Free Software Foundation, Inc. -# -# This file is part of Postorius. -# -# Postorius is free software: you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free -# Software Foundation, either version 3 of the License, or (at your option) -# any later version. -# Postorius is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along with -# Postorius. If not, see . - -import os - -from django.conf import settings -from mailmanclient.testing.vcr_helpers import get_vcr - - -TEST_ROOT = os.path.abspath(os.path.dirname(__file__)) - -FIXTURES_DIR = getattr( - settings, 'FIXTURES_DIR', - os.path.join(TEST_ROOT, 'fixtures')) - -VCR_RECORD_MODE = os.environ.get( - 'POSTORIUS_VCR_RECORD_MODE', - getattr(settings, 'VCR_RECORD_MODE', 'once')) - -MM_VCR = get_vcr( - cassette_library_dir=os.path.join(FIXTURES_DIR, 'vcr_cassettes'), - record_mode=VCR_RECORD_MODE, - ) diff --git a/src/postorius/tests/mailman_api_tests/test_domain_delete.py b/src/postorius/tests/mailman_api_tests/test_domain_delete.py index e5b7fbe..d8ae96e 100644 --- a/src/postorius/tests/mailman_api_tests/test_domain_delete.py +++ b/src/postorius/tests/mailman_api_tests/test_domain_delete.py @@ -19,10 +19,6 @@ from django.core.urlresolvers import reverse from django.contrib.auth.models import User -try: - from urllib2 import HTTPError -except ImportError: - from urllib.error import HTTPError from postorius.tests.utils import ViewTestCase diff --git a/src/postorius/tests/mailman_api_tests/test_domain_new.py b/src/postorius/tests/mailman_api_tests/test_domain_new.py index 1337c83..7ae861e 100644 --- a/src/postorius/tests/mailman_api_tests/test_domain_new.py +++ b/src/postorius/tests/mailman_api_tests/test_domain_new.py @@ -20,11 +20,6 @@ from django.contrib.auth.models import User from django.core.urlresolvers import reverse -try: - from urllib2 import HTTPError -except ImportError: - from urllib.error import HTTPError - from postorius.tests.utils import ViewTestCase diff --git a/src/postorius/tests/mailman_api_tests/test_subscriptions.py b/src/postorius/tests/mailman_api_tests/test_subscriptions.py index e687cba..c3e14b8 100644 --- a/src/postorius/tests/mailman_api_tests/test_subscriptions.py +++ b/src/postorius/tests/mailman_api_tests/test_subscriptions.py @@ -162,9 +162,9 @@ test-3@example.org (Third Person)\n test-4@example.org\n \n""" - response = self.client.post( - reverse('mass_subscribe', args=('open_list.example.com',)), - {'emails': email_list}) + self.client.post(reverse('mass_subscribe', + args=('open_list.example.com',)), + {'emails': email_list}) self.assertEqual(len(self.open_list.members), 5) first = self.open_list.get_member('test-1@example.org') second = self.open_list.get_member('test-2@example.org') diff --git a/src/postorius/tests/mailman_api_tests/test_user.py b/src/postorius/tests/mailman_api_tests/test_user.py index 81566c6..94ed405 100644 --- a/src/postorius/tests/mailman_api_tests/test_user.py +++ b/src/postorius/tests/mailman_api_tests/test_user.py @@ -58,8 +58,6 @@ self.assertEqual(response.status_code, 200) self.assertEqual(len(response.context["formset"]), 3) self.assertEqual(len(response.context["zipped_data"]), 3) - #self.assertEqual( - # response.context["formset"].initial['archive_policy'], 'public') def test_preferences_none(self): # Mailman does not accept None values for boolean preferences. When diff --git a/src/postorius/tests/utils.py b/src/postorius/tests/utils.py index 850519b..7908b72 100644 --- a/src/postorius/tests/utils.py +++ b/src/postorius/tests/utils.py @@ -15,6 +15,7 @@ # You should have received a copy of the GNU General Public License along with # Postorius. If not, see . +import os import logging from django.conf import settings @@ -25,8 +26,7 @@ from six.moves.urllib_parse import quote from postorius.utils import get_client -from postorius.tests import MM_VCR - +from mailmanclient.testing.vcr_helpers import get_vcr vcr_log = logging.getLogger('vcr') vcr_log.setLevel(logging.WARNING) @@ -105,11 +105,15 @@ class ViewTestCase(TestCase): use_vcr = True + _fixtures_dir = os.path.join(os.path.abspath( + os.path.dirname(__file__)), 'fixtures', 'vcr_cassettes') + + _mm_vcr = get_vcr(cassette_library_dir=_fixtures_dir) def setUp(self): self.mm_client = get_client() if self.use_vcr: - cm = MM_VCR.use_cassette('.'.join([ + cm = self._mm_vcr.use_cassette('.'.join([ self.__class__.__name__, self._testMethodName, 'yaml'])) self.cassette = cm.__enter__() self.addCleanup(cm.__exit__, None, None, None) diff --git a/testing/test_settings.py b/testing/test_settings.py index a5e8329..d425374 100755 --- a/testing/test_settings.py +++ b/testing/test_settings.py @@ -153,8 +153,3 @@ 'django.contrib.auth.backends.ModelBackend', 'django_browserid.auth.BrowserIDBackend', ) - - -# Set VCR_RECORD_MODE to 'all' to re-record all API responses. -# (Remember to use an empty mailman database!) -VCR_RECORD_MODE = 'once'