コード例 #1
0
ファイル: test_send.py プロジェクト: webkom/lego
    def test_send_to_group_with_several_leaders(self, mock_send_email):
        """
        Test that all leaders receive the form.
        """
        logged_in_user = User.objects.first()

        self.webkom_group.add_user(logged_in_user, role=LEADER)

        send_message("title", "message", logged_in_user, True,
                     self.webkom_group)
        mock_send_email.assert_called_with(
            to_email=[
                self.webkom_leader.email_address, logged_in_user.email_address
            ],
            context={
                "title": "title",
                "message": "message",
                "from_name": "Anonymous",
                "from_email": "Unknown",
                "recipient_group": self.webkom_group.__str__(),
            },
            subject=
            f"Ny henvendelse fra kontaktskjemaet til {self.webkom_group.__str__()}",
            **default_values,
        )
        mock_send_email.assert_called_once()
コード例 #2
0
ファイル: test_send.py プロジェクト: vhellem/lego
    def test_send_user_set_anonymous(self, mock_send_email):
        """
        Send in a contact form as logged in user, set to be anonymous
        """
        logged_in_user = User.objects.first()

        send_message('title', 'message', logged_in_user, True)
        mock_send_email.assert_called_with(to_email="*****@*****.**",
                                           context={
                                               'title': 'title',
                                               'message': 'message',
                                               'from_name': "Anonymous",
                                               'from_email': "Unknown"
                                           },
                                           **default_values)
        mock_send_email.assert_called_once()
コード例 #3
0
ファイル: test_send.py プロジェクト: vhellem/lego
    def test_send_anonymous_user(self, mock_send_email):
        """
        Send in a contact form as not logged in user
        """
        anonymus_user = AnonymousUser()

        send_message('title', 'message', anonymus_user, False)
        mock_send_email.assert_called_with(to_email="*****@*****.**",
                                           context={
                                               'title': 'title',
                                               'message': 'message',
                                               'from_name': "Anonymous",
                                               'from_email': "Unknown"
                                           },
                                           **default_values)
        mock_send_email.assert_called_once()
コード例 #4
0
ファイル: test_send.py プロジェクト: vhellem/lego
    def test_send_user(self, mock_send_email):
        """
        Send in a contact form as logged in user, showing name
        """
        logged_in_user = User.objects.first()

        send_message('title', 'message', logged_in_user, False)
        mock_send_email.assert_called_with(to_email="*****@*****.**",
                                           context={
                                               'title':
                                               'title',
                                               'message':
                                               'message',
                                               'from_name':
                                               logged_in_user.full_name,
                                               'from_email':
                                               logged_in_user.email_address
                                           },
                                           **default_values)
        mock_send_email.assert_called_once()
コード例 #5
0
ファイル: test_send.py プロジェクト: webkom/lego
    def test_send_user(self, mock_send_email):
        """
        Send in a contact form as logged in user, showing name
        """
        logged_in_user = User.objects.first()

        send_message("title", "message", logged_in_user, False,
                     self.webkom_group)
        mock_send_email.assert_called_with(
            to_email=[self.webkom_leader.email_address],
            context={
                "title": "title",
                "message": "message",
                "from_name": logged_in_user.full_name,
                "from_email": logged_in_user.email_address,
                "recipient_group": self.webkom_group.__str__(),
            },
            subject=
            f"Ny henvendelse fra kontaktskjemaet til {self.webkom_group.__str__()}",
            **default_values,
        )
        mock_send_email.assert_called_once()
コード例 #6
0
ファイル: test_send.py プロジェクト: webkom/lego
    def test_send_anonymous_user(self, mock_send_email):
        """
        Send in a contact form as not logged in user
        """
        anonymus_user = AnonymousUser()

        send_message("title", "message", anonymus_user, False,
                     self.webkom_group)
        mock_send_email.assert_called_with(
            to_email=[self.webkom_leader.email_address],
            context={
                "title": "title",
                "message": "message",
                "from_name": "Anonymous",
                "from_email": "Unknown",
                "recipient_group": self.webkom_group.__str__(),
            },
            subject=
            f"Ny henvendelse fra kontaktskjemaet til {self.webkom_group.__str__()}",
            **default_values,
        )
        mock_send_email.assert_called_once()
コード例 #7
0
ファイル: test_send.py プロジェクト: webkom/lego
    def test_send_to_hs(self, mock_send_email):
        """
        Send in a contact form to HS by passing `None` as recipient
        """
        anonymus_user = AnonymousUser()
        hs_group = AbakusGroup.objects.get(name="Hovedstyret")

        send_message("title", "message", anonymus_user, True, None)
        mock_send_email.assert_called_with(
            to_email=["*****@*****.**"],
            context={
                "title": "title",
                "message": "message",
                "from_name": "Anonymous",
                "from_email": "Unknown",
                "recipient_group": hs_group.__str__(),
            },
            subject=
            f"Ny henvendelse fra kontaktskjemaet til {hs_group.__str__()}",
            **default_values,
        )
        mock_send_email.assert_called_once()
コード例 #8
0
ファイル: test_send.py プロジェクト: webkom/lego
    def test_is_only_sent_to_leader(self, mock_send_email):
        """
        Test that form is only sent to leader, not other members.
        """
        logged_in_user = User.objects.first()

        self.webkom_group.add_user(logged_in_user, role=MEMBER)

        send_message("title", "message", logged_in_user, True,
                     self.webkom_group)
        mock_send_email.assert_called_with(
            to_email=[self.webkom_leader.email_address],
            context={
                "title": "title",
                "message": "message",
                "from_name": "Anonymous",
                "from_email": "Unknown",
                "recipient_group": self.webkom_group.__str__(),
            },
            subject=
            f"Ny henvendelse fra kontaktskjemaet til {self.webkom_group.__str__()}",
            **default_values,
        )
        mock_send_email.assert_called_once()
コード例 #9
0
ファイル: test_send.py プロジェクト: estensen/lego
 def test_send_user(self, mock_send_email):
     send_message('title', 'message', User.objects.first(), False)
     mock_send_email.assert_called_once()
コード例 #10
0
ファイル: test_send.py プロジェクト: estensen/lego
 def test_send_anonymous_user(self, mock_send_email):
     send_message('title', 'message', AnonymousUser(), False)
     mock_send_email.assert_called_once()