def test_save_method(self): form_data = { 'first_name': 'Vasya', 'last_name': 'Ivanov', 'username': '******', 'email': '*****@*****.**', 'password1': 't1e2s3t4', 'password2': 't1e2s3t4', } form = tm_forms.CustomRegistrationForm(data=form_data) self.assertTrue(form.is_valid()) user = form.save() self.assertTrue(isinstance(user, User)) self.assertEquals(user.first_name, 'Vasya') self.assertEquals(user.last_name, 'Ivanov')
def test_field_last_name_validation(self): form = tm_forms.CustomRegistrationForm() regex_validator = form.fields['last_name'].validators[0] self.assertEquals(regex_validator.regex.pattern, '^[a-zA-Zа-яА-Я]+$')
def test_field_last_name_help_text(self): form = tm_forms.CustomRegistrationForm() self.assertEquals(form.fields['last_name'].help_text, 'Required. Letters Only')
def test_field_last_name_required(self): form = tm_forms.CustomRegistrationForm() self.assertTrue(form.fields['last_name'].required)
def test_field_last_name_max_length(self): form = tm_forms.CustomRegistrationForm() self.assertEquals(form.fields['last_name'].max_length, 100)
def test_field_last_name_label(self): form = tm_forms.CustomRegistrationForm() self.assertEquals(form.fields['last_name'].label, 'Last name')