Пример #1
0
    def test_submit_form_without_phone_passes(self):
        email = Faker().email()
        issuer = IssuerFactory.build(email=email)

        self.__open_form_url()

        self.__fill_form_and_submit(
            issuer, ["first_name", "last_name", "email", "profession"])

        path = reverse(
            "habilitation_issuer_email_confirmation_waiting",
            kwargs={"issuer_id": Issuer.objects.get(email=email).issuer_id},
        )

        WebDriverWait(self.selenium, 10).until(url_matches(f"^.+{path}$"))
Пример #2
0
    def test_email_confirmation_process(self, send_mail_mock: Mock):
        email = Faker().email()
        issuer = IssuerFactory.build(email=email)

        self.__open_form_url()

        self.__fill_form_and_submit(
            issuer,
            ["first_name", "last_name", "email", "profession", "phone"])

        path = reverse(
            "habilitation_issuer_email_confirmation_waiting",
            kwargs={"issuer_id": Issuer.objects.get(email=email).issuer_id},
        )

        WebDriverWait(self.selenium, 10).until(url_matches(f"^.+{path}$"))

        send_mail_mock.assert_called_with(
            from_email=ANY,
            recipient_list=[email],
            subject=ANY,
            message=ANY,
            html_message=ANY,
        )

        # Test resend mail
        send_mail_mock.reset_mock()
        send_mail_mock.assert_not_called()

        self.selenium.find_element(
            By.XPATH,
            """//button[normalize-space() = "Renvoyer l'email de confirmation"]""",
        ).click()

        send_mail_mock.assert_called_with(
            from_email=ANY,
            recipient_list=[email],
            subject=ANY,
            message=ANY,
            html_message=ANY,
        )

        # Confirm email
        issuer = Issuer.objects.get(email=email)
        email_confirmation = issuer.email_confirmations.first()

        self.open_live_url(
            reverse(
                "habilitation_issuer_email_confirmation_confirm",
                kwargs={
                    "issuer_id": issuer.issuer_id,
                    "key": email_confirmation.key
                },
            ))

        self.selenium.find_element(By.CSS_SELECTOR, '[type="submit"]').click()

        path = reverse(
            "habilitation_new_organisation",
            kwargs={"issuer_id": issuer.issuer_id},
        )

        WebDriverWait(self.selenium, 10).until(url_matches(f"^.+{path}$"))