Ejemplo n.º 1
0
 def test_validation_for_all_items(self):
     form = AidantCreationForm(data=self.data.copy())
     self.assertTrue(form.is_valid())
     form.save()
     self.assertEqual(Aidant.objects.all().count(), 2)
     new_aidant = Aidant.objects.get(email="*****@*****.**")
     self.assertEqual(new_aidant.username, "*****@*****.**")
Ejemplo n.º 2
0
 def field_test(name_of_field: str, data_set: dict) -> None:
     data_set[name_of_field] = ""
     form = AidantCreationForm(data=data_set)
     self.assertFalse(
         form.is_valid(),
         f"Field {name_of_field} is considered valid, it should not.",
     )
     self.assertEqual(form.errors[name_of_field],
                      ["Ce champ est obligatoire."])
Ejemplo n.º 3
0
    def test_cannot_create_new_aidant_with_unsound_password(self):
        data_set = self.data.copy()

        # settings.py AUTH_PASSWORD_VALIDATORS.MinimumLengthValidator
        data_set["password"] = "******"
        form = AidantCreationForm(data=data_set)
        self.assertFalse(form.is_valid())

        # settings.py AUTH_PASSWORD_VALIDATORS.CommonPasswordValidator
        data_set["password"] = "******"
        form = AidantCreationForm(data=data_set)
        self.assertFalse(form.is_valid())

        # settings.py AUTH_PASSWORD_VALIDATORS.UserAttributeSimilarityValidator
        data_set["password"] = "******"
        form = AidantCreationForm(data=data_set)
        self.assertFalse(form.is_valid())

        # settings.py AUTH_PASSWORD_VALIDATORS.NumericPasswordValidator
        data_set["password"] = "******"
        form = AidantCreationForm(data=data_set)
        self.assertFalse(form.is_valid())
Ejemplo n.º 4
0
    def test_cannot_create_new_aidant_with_same_email(self):
        AidantFactory(
            first_name="Henri",
            last_name="Bernart",
            email="*****@*****.**",
            username="******",
            password="******",
            profession="Mediateur",
            organisation=self.organisation,
        )

        form = AidantCreationForm(data=self.data)
        self.assertFalse(form.is_valid())
Ejemplo n.º 5
0
    def test_cannot_create_new_aidant_with_same_email(self):
        Aidant.objects.create(
            first_name="Henri",
            last_name="Bernart",
            email="*****@*****.**",
            username="******",
            password="******",
            profession="Mediateur",
            organisme="Association Aide au Numérique",
            ville="Nîmes",
        )

        form = AidantCreationForm(data=self.data)
        self.assertFalse(form.is_valid())
Ejemplo n.º 6
0
 def field_test(name_of_field: str, data_set: dict) -> None:
     data_set[name_of_field] = ""
     form = AidantCreationForm(data=data_set)
     self.assertFalse(form.is_valid())
     self.assertEqual(form.errors[name_of_field],
                      ["Ce champ est obligatoire."])