Exemplo n.º 1
0
    def test_expired_invitation_with_new_user(self):
        invitation = PrescriberWithOrgSentInvitationFactory(sender=self.sender, organization=self.organization)
        invitation.sent_at -= timedelta(days=invitation.EXPIRATION_DAYS)
        invitation.save()
        self.assertTrue(invitation.has_expired)

        post_data = {
            "first_name": invitation.first_name,
            "last_name": invitation.last_name,
            "password1": "Erls92#32",
            "password2": "Erls92#32",
        }
        response = self.client.post(invitation.acceptance_link, data=post_data, follow=True)
        self.assertContains(response, escape("Cette invitation n'est plus valide."))
Exemplo n.º 2
0
    def test_expired_invitation_with_existing_user(self):
        user = PrescriberFactory()
        invitation = PrescriberWithOrgSentInvitationFactory(
            first_name=user.first_name,
            last_name=user.last_name,
            email=user.email,
            sender=self.sender,
            organization=self.organization,
        )
        invitation.sent_at -= timedelta(days=invitation.EXPIRATION_DAYS)
        invitation.save()
        self.assertTrue(invitation.has_expired)

        # GET or POST in this case
        response = self.client.get(invitation.acceptance_link, follow=True)
        self.assertContains(response, escape("Cette invitation n'est plus valide."))

        self.client.login(email=user.email, password=DEFAULT_PASSWORD)
        # Try to bypass the first check by directly reaching the join endpoint
        join_url = reverse("invitations_views:join_prescriber_organization", kwargs={"invitation_id": invitation.id})
        response = self.client.get(join_url, follow=True)
        # The 2 views return the same error message
        self.assertContains(response, escape("Cette invitation n'est plus valide."))