1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2019-2023 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)
11 # Postorius is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 # You should have received a copy of the GNU General Public License along with
17 # Postorius. If not, see <http://www.gnu.org/licenses/>.
22 from postorius
.templatetags
.nav_helpers
import (
24 pending_subscriptions
,
26 from postorius
.tests
.utils
import ViewTestCase
29 class TestNavigationHelpers(ViewTestCase
):
33 self
.domain
= self
.mm_client
.create_domain('example.com')
34 self
.mlist
= self
.domain
.create_list('test_list')
39 def test_subscription_request_count(self
):
40 # Initially, the count of held messages is 0.
41 self
.assertEqual(pending_subscriptions(self
.mlist
), 0)
42 self
.mlist
.settings
['subscription_policy'] = 'moderate'
43 self
.mlist
.settings
.save()
44 self
.mlist
.subscribe('needsmoderation@example.com', pre_verified
=True)
45 self
.assertEqual(pending_subscriptions(self
.mlist
), 1)
46 # Make sure the ones pending user approval don't show up.
47 self
.mlist
.settings
['subscription_policy'] = 'confirm'
48 self
.mlist
.settings
.save()
50 'needsconfirmation@example.com', pre_verified
=True
52 self
.assertEqual(pending_subscriptions(self
.mlist
), 1)
54 def test_held_message_count(self
):
55 # Initially, the count of held messages is 0.
56 self
.assertEqual(held_count(self
.mlist
), 0)
57 # Now, let's inject some message.
59 From: nonmember@example.com
60 To: test_list@example.com
62 Message-ID: <moderated_01>
66 inq
= self
.mm_client
.queues
['in']
67 inq
.inject('test_list.example.com', msg
)
68 # Wait for the message to be processed.
70 if len(inq
.files
) == 0:
73 # Wait for message to show up in held queue.
75 all_held
= self
.mlist
.held
80 self
.assertEqual(held_count(self
.mlist
), 1)