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)
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
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
):
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)
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)
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
))