Exemplo n.º 1
0
def test_notification_email_last_sent_at_updated():
    user1 = UserFactory()
    _ = NotificationFactory(user=user1, type=Notification.Type.GENERIC)
    assert not user1.user_profile.notification_email_last_sent_at
    send_unread_notification_emails()
    user1.refresh_from_db()
    assert user1.user_profile.notification_email_last_sent_at
Exemplo n.º 2
0
 def test_post_user_edit(self):
     user = UserFactory(username="******")
     data = {"username": "******"}
     with self.login(self.user):
         self.post("backoffice:user-edit", pk=user.pk, data=data)
     self.response_302()
     user.refresh_from_db()
     self.assertEqual(data["username"], user.username)
Exemplo n.º 3
0
    def test_user_can_not_verify_other_token(self, settings):
        settings.task_eager_propagates = (True, )
        settings.task_always_eager = (True, )

        u1 = UserFactory()
        v1 = VerificationFactory(user=u1)

        u2 = UserFactory()

        form = ConfirmEmailForm(user=u2,
                                token=v1.token,
                                data={"token": v1.token})

        assert not form.is_valid()
        assert ["Token is invalid"] == form.errors["token"]

        u1.refresh_from_db()
        u2.refresh_from_db()
        v1.refresh_from_db()

        assert u1.is_active is True
        assert u2.is_active is False
        assert v1.is_verified is None