コード例 #1
0
 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')
コード例 #2
0
 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а-яА-Я]+$')
コード例 #3
0
 def test_field_last_name_help_text(self):
     form = tm_forms.CustomRegistrationForm()
     self.assertEquals(form.fields['last_name'].help_text,
                       'Required. Letters Only')
コード例 #4
0
 def test_field_last_name_required(self):
     form = tm_forms.CustomRegistrationForm()
     self.assertTrue(form.fields['last_name'].required)
コード例 #5
0
 def test_field_last_name_max_length(self):
     form = tm_forms.CustomRegistrationForm()
     self.assertEquals(form.fields['last_name'].max_length, 100)
コード例 #6
0
 def test_field_last_name_label(self):
     form = tm_forms.CustomRegistrationForm()
     self.assertEquals(form.fields['last_name'].label, 'Last name')