def test_employer_register_form_is_invalid(self):
     self.form_data = {
         'first_name': 'test_fn',
         'last_name': 'test_ln',
         'password2': 'password',
         'email': '*****@*****.**',
         'description': 'job_desc',
         'mobile': 9348963248,
         'address': 'address',
         'country': countries[1][0],
     }
     form = EmployerRegisterForm(data=self.form_data)
     self.assertFalse(form.is_valid())
Esempio n. 2
0
 def setUp(self):
     self.form = EmployerRegisterForm(
         data={
             'mobile': 1234567890,
             'description': 'user_desc1',
             'country': countries[0][0],
             'address': 'address1',
             'first_name': 'first_name',
             'last_name': 'last_name',
             'username': '******',
             'email': '*****@*****.**',
             'password1': 'Password123!',
             'password2': 'Password123!',
         })
Esempio n. 3
0
 def test_employer_form_valid_data(self):
     form = EmployerRegisterForm(
         data={
             'mobile': 1234567890,
             'description': 'user_desc1',
             'country': countries[0][0],
             'address': 'address1',
             'first_name': 'first_name',
             'last_name': 'last_name',
             'username': '******',
             'email': '*****@*****.**',
             'password1': 'Password123!',
             'password2': 'Password123!'
         })
     self.assertTrue(form.is_valid())
Esempio n. 4
0
class TestEmployerRegistrationForm(TestCase):
    def setUp(self):
        self.form = EmployerRegisterForm(
            data={
                'mobile': 1234567890,
                'description': 'user_desc1',
                'country': countries[0][0],
                'address': 'address1',
                'first_name': 'first_name',
                'last_name': 'last_name',
                'username': '******',
                'email': '*****@*****.**',
                'password1': 'Password123!',
                'password2': 'Password123!',
            })

    def test_password1_field_label(self):
        self.assertTrue(self.form.fields['password1'].label is None
                        or self.form.fields['password1'].label == 'Password')

    def test_password1_field_help_text(self):
        self.assertEqual(
            self.form.fields['password1'].help_text,
            password_validation.password_validators_help_text_html())

    def test_password2_field_label(self):
        self.assertTrue(
            self.form.fields['password2'].label == 'Password confirmation')

    def test_mobile_max_length(self):
        max_length = self.form.fields['mobile'].max_length
        self.assertEquals(max_length, 15)

    def test_form_valid_data(self):
        self.assertTrue(self.form.is_valid())

    def test_form_invalid_mobile_max_length(self):
        self.form.data['mobile'] = 12345678901234567890
        self.assertFalse(self.form.is_valid())

    def test_form_password_mismatch(self):
        self.form.data['password2'] = 'passmismatch'
        self.assertFalse(self.form.is_valid())

    def test_form_invalid_email(self):
        self.form.data['email'] = 'wrong_email'
        self.assertFalse(self.form.is_valid())

    def test_form_invalid_country(self):
        self.form.data['country'] = 'wrong_country'
        self.assertFalse(self.form.is_valid())

    def test_form_unfilled_data(self):
        form = FreelancerRegisterForm(
            data={
                'mobile': 1234567890,
                'country': countries[0][0],
                'address': 'address1',
                'first_name': 'first_name',
                'last_name': 'last_name',
                'email': '*****@*****.**',
                'password1': 'Password123!',
                'password2': 'Password123!'
            })
        self.assertFalse(form.is_valid())

    def test_employer_form_valid_data(self):
        form = EmployerRegisterForm(
            data={
                'mobile': 1234567890,
                'description': 'user_desc1',
                'country': countries[0][0],
                'address': 'address1',
                'first_name': 'first_name',
                'last_name': 'last_name',
                'username': '******',
                'email': '*****@*****.**',
                'password1': 'Password123!',
                'password2': 'Password123!'
            })
        self.assertTrue(form.is_valid())
 def test_employer_register_form_valid_function(self):
     form = EmployerRegisterForm(data=self.form_data)
     url = EmployerRegisterFormView.form_valid(EmployerRegisterFormView(),
                                               form).url
     self.assertEqual(reverse('accounts:login'), url)
 def test_employer_register_form_is_valid(self):
     form = EmployerRegisterForm(data=self.form_data)
     self.assertTrue(form.is_valid())