Bump version to 1.3.6 and update NEWS.rst for 1.3.5
[mailman-postorious.git] / src / postorius / tests / mailman_api_tests / test_models.py
blob09230c3f959063fae5483f971615465713085de2
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2012-2021 by the Free Software Foundation, Inc.
4 # This file is part of Postorius.
6 # Postorius is free software: you can redistribute it and/or modify it under
7 # the terms of the GNU General Public License as published by the Free
8 # Software Foundation, either version 3 of the License, or (at your option)
9 # any later version.
10 # Postorius is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 # more details.
15 # You should have received a copy of the GNU General Public License along with
16 # Postorius. If not, see <http://www.gnu.org/licenses/>.
18 from postorius.models import MailmanListManager
19 from postorius.tests.utils import ViewTestCase
22 class TestMailmanListManager(ViewTestCase):
24 def setUp(self):
25 super().setUp()
26 self.domain = self.mm_client.create_domain('example.com')
27 self.domain2 = self.mm_client.create_domain('most-desirable.org')
28 self.foo_list = self.domain.create_list('foo')
29 self.bar_list = self.domain.create_list('bar')
30 self.baz_list = self.domain2.create_list('baz')
31 self.list_manager = MailmanListManager()
33 def test_get_all_mailinglists(self):
34 lists = self.list_manager.all()
35 # This should return all the 2 mailing lists that we have.
36 self.assertEqual(len(lists), 3)
37 self.assertEqual(
38 [x.fqdn_listname for x in lists],
39 ['bar@example.com', 'baz@most-desirable.org', 'foo@example.com'])
41 def test_get_by_mail_host(self):
42 lists = self.list_manager.by_mail_host('example.com')
43 self.assertEqual(len(lists), 2)
44 self.assertEqual(
45 [x.fqdn_listname for x in lists],
46 ['bar@example.com', 'foo@example.com'])
48 def test_get_single_mailinglist(self):
49 mlist = self.list_manager.get('baz@most-desirable.org')
50 self.assertIsNotNone(mlist)
51 self.assertEqual(str(mlist), str(self.baz_list))