Example #1
0
    def test_field_required(self):
        form = EmployeeRegistrationForm(data={})

        self.assertEqual(form.errors["gender"], ["Gender is required"])
        self.assertEqual(form.errors["email"], ["This field is required."])
        self.assertEqual(form.errors["password1"], ["This field is required."])
        self.assertEqual(form.errors["password2"], ["This field is required."])
Example #2
0
    def test_password_mismatch(self):
        # Set confirm password field to a different value
        data = self.valid_user
        data['password2'] = '54321'

        form = EmployeeRegistrationForm(data)

        self.assertFalse(form.is_valid())
        self.assertEqual(form.errors['password2'][0], 'The two password fields didn’t match.')
Example #3
0
 def setUp(self) -> None:
     self.form = EmployeeRegistrationForm(
         data={
             'password1': "Mahesh@94",
             'user_gender': "male",
             'first_name': "abc",
             'last_name': "xyz",
             'password2': "Mahesh@94",
             'user_link': "likdin.com",
             'email': "*****@*****.**"
         }
     )
     self.form_update = UpdateEmployeeForm(
         data={
             'password1': "Mahesh@94",
             'user_gender': "male",
             'first_name': "abc",
             'last_name': "xyz",
             'password2': "Mahesh@94",
             'user_link': "likdin.com",
             'email': "*****@*****.**"
         }
     )
Example #4
0
 def test_valid_and_save_form(self):
     form = EmployeeRegistrationForm(data=self.valid_user)
     form.is_valid()
     user = form.save()
     self.assertIsInstance(user, User, "Not an user")
Example #5
0
 def test_too_short_password(self):
     data = self.valid_user
     data["password1"] = "test"
     form = EmployeeRegistrationForm(data=data)
     self.assertFalse(form.is_valid())
Example #6
0
 def test_invalid_email(self):
     data = self.valid_user
     data["email"] = "test"
     form = EmployeeRegistrationForm(data=data)
     self.assertFalse(form.is_valid(), "Invalid email")
Example #7
0
 def test_employee_registration_form_valid(self):
     form = EmployeeRegistrationForm(data=self.valid_user)
     self.assertEqual(True, form.is_valid(), "Invalid form")
Example #8
0
 def test__clean__ok(self):
     form = EmployeeRegistrationForm()
     form.save()
     assert form.fields["first_name"].label == "First Name"