def test_cannot_make_validation_with_someone_elses_email(self):
        u1 = UserFactory(email="*****@*****.**")
        u2 = UserFactory()

        form = VerificationForm(
            user=u2, data={"email": u1.email, "user": u2.pk}
        )
        assert ["This email is already in use"] == form.errors["email"]

        form = VerificationForm(
            user=u2, data={"email": u1.email.upper(), "user": u2.pk}
        )
        assert ["This email is already in use"] == form.errors["email"]
    def test_can_only_create_one_validation(self):
        u = UserFactory()
        VerificationFactory(user=u)
        form = VerificationForm(user=u, data={"email": u.email, "user": u})

        assert ["You have already made a verification request"
                ] == form.errors["__all__"]
    def test_cannot_make_validation_with_other_validation_email(self):
        call_command("check_permissions")
        u = UserenaSignup.objects.create_user(
            "userena", "*****@*****.**", "testpassword", active=True
        )

        v = VerificationFactory(user=u)
        form = VerificationForm(user=UserFactory(), data={"email": v.email})

        assert ["This email is already in use"] == form.errors["email"]
    def test_can_only_create_one_validation(self):
        call_command("check_permissions")
        u = UserenaSignup.objects.create_user(
            "userena", "*****@*****.**", "testpassword", active=True
        )

        VerificationFactory(user=u)
        form = VerificationForm(user=u, data={"email": u.email, "user": u})

        assert ["You have already made a verification request"] == form.errors[
            "__all__"
        ]
    def test_can_make_validation_with_own_email(self):
        u = UserFactory(email="*****@*****.**")

        form = VerificationForm(user=u, data={"email": u.email, "user": u.pk})
        assert form.is_valid()

        form = VerificationForm(
            user=u, data={"email": u.email.upper(), "user": u.pk}
        )
        assert form.is_valid()
    def test_cannot_make_validation_with_other_validation_email(self):
        u = UserFactory()
        v = VerificationFactory(user=u)
        form = VerificationForm(user=UserFactory(), data={"email": v.email})

        assert ["This email is already in use"] == form.errors["email"]
    def test_email_domain(self, email, error):
        form = VerificationForm(user=UserFactory(), data={"email": email})

        assert [error] == form.errors["email"]