diff --git a/src/postorius/tests/__init__.py b/src/postorius/tests/__init__.py index 4c4c11a..92479f3 100644 --- a/src/postorius/tests/__init__.py +++ b/src/postorius/tests/__init__.py @@ -16,15 +16,9 @@ # Postorius. If not, see . from postorius.tests import test_utils -from postorius.tests.test_list_members import * -from postorius.tests.test_auth_decorators import * -from postorius.tests.test_user_creation_sync import * __test__ = { "Test Utils": test_utils, - "List members": ListMembersViewTest, - "List Owner Required": ListOwnerRequiredTest, - "Sync Postorius users and Mailman users": UserCreationSyncTest, # "Page Tests": test_pages, #"Doctest": tests, } diff --git a/src/postorius/tests/test_list_members.py b/src/postorius/tests/test_list_members.py deleted file mode 100644 index 6b2d860..0000000 --- a/src/postorius/tests/test_list_members.py +++ /dev/null @@ -1,96 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2012 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 . - -from django.contrib.auth.models import AnonymousUser, User -from django.core.exceptions import PermissionDenied -from django.utils import unittest -from mock import patch - - -class ListMembersViewTest(unittest.TestCase): - """Tests for the ListMembersView.""" - - def setUp(self): - from django.test.client import RequestFactory - from postorius.tests.utils import create_mock_list, create_mock_member - self.request_factory = RequestFactory() - # create a mock list with members - list_name = 'foolist@example.org' - self.mock_list = create_mock_list(dict( - fqdn_listname=list_name, - members=[ - create_mock_member(dict( - fqdn_listname=list_name, - address='les@example.org')), - create_mock_member(dict( - fqdn_listname=list_name, - address='ler@example.com')), - ])) - - def test_get_list(self): - """Test if list members are retreived correctly.""" - from postorius.views import ListMembersView - # test get_list - view = ListMembersView() - with patch('mailmanclient.Client.get_list') as mock: - mock.return_value = self.mock_list - the_list = view._get_list('foolist@example.org') - self.assertEqual(the_list.members[0].address, 'les@example.org') - self.assertEqual(the_list.members[1].address, 'ler@example.com') - - def test_dispatch(self): - """Test if list members are retreived correctly.""" - from postorius.views import ListMembersView - # test get_list - view = ListMembersView() - with patch('mailmanclient.Client.get_list') as mock: - mock.return_value = self.mock_list - the_list = view._get_list('foolist@example.org') - request = self.request_factory.get( - '/lists/foolist@example.org/members/') - request.user = User.objects.create_superuser('sux', 'su@sodo.org', - 'pwd') - view.dispatch(request, fqdn_listname='foolist@example.org') - self.assertEqual(self.mock_list, view.mailing_list) - - def test_return_code_by_user(self): - """Test response status code by user status. - """ - from postorius.views import ListMembersView - with patch('mailmanclient.Client.get_list') as mock: - mock.return_value = self.mock_list - request = self.request_factory.get( - '/lists/foolist@example.org/members/') - # anonymous users should be redirected - request.user = AnonymousUser() - self.assertRaises(PermissionDenied, ListMembersView.as_view(), - request, fqdn_listname='foolist@example.org') - # logged in users should be redirected - request.user = User.objects.create_user('les', 'les@primus.org', - 'pwd') - self.assertRaises(PermissionDenied, ListMembersView.as_view(), - request, fqdn_listname='foolist@example.org') - # superusers should get the page - request.user = User.objects.create_superuser('su', 'su@sodo.org', - 'pwd') - response = ListMembersView.as_view()( - request, - fqdn_listname='foolist@example.org') - self.assertEqual(response.status_code, 200) - - def tearDown(self): - pass diff --git a/src/postorius/tests/test_user_creation_sync.py b/src/postorius/tests/test_user_creation_sync.py deleted file mode 100644 index 0850866..0000000 --- a/src/postorius/tests/test_user_creation_sync.py +++ /dev/null @@ -1,35 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2012 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 . - -from django.contrib.auth.models import AnonymousUser, User -from django.core.exceptions import PermissionDenied -from django.test.client import RequestFactory -from postorius.tests.utils import create_mock_list -from django.utils import unittest -from mock import patch - -from postorius.auth.decorators import (list_owner_required, - list_moderator_required) -from postorius.models import (Domain, List, Member, MailmanUser, - MailmanApiError, Mailman404Error) -from mailmanclient import Client - - -class UserCreationSyncTest(unittest.TestCase): - """Tests if a newly saved db user is synced to the mailman core. - """ - pass