示例#1
0
 def test_form_field_classes(self):
     form = tm_forms.TaskForm()
     self.assertTrue(
         isinstance(form.fields['creator'], tm_fields.UserModelChoiceField))
     self.assertTrue(form.fields['creator'].disabled)
     self.assertEquals(
         form.fields['creator'].label_from_instance(self.ivanov),
         self.ivanov.get_full_name())
     self.assertTrue(
         isinstance(form.fields['assigned_to'],
                    tm_fields.UserModelChoiceField))
     self.assertEquals(
         form.fields['assigned_to'].label_from_instance(self.ivanov),
         self.ivanov.get_full_name())
     self.assertTrue(form.fields['tags'], tm_fields.TagsField)
示例#2
0
 def test_field_tags_instance_as_initial(self):
     form = tm_forms.TaskForm(instance=self.task)
     self.assertEquals(form.initial['tags'], 'task|test')
示例#3
0
 def test_field_tags_validators_validate_tags(self):
     form = tm_forms.TaskForm()
     self.assertEquals(form.fields['tags'].validators[2],
                       tm_fields.validate_tags)
示例#4
0
 def test_field_tags_validators_regex(self):
     form = tm_forms.TaskForm()
     regex_validator = form.fields['tags'].validators[1]
     self.assertTrue(isinstance(regex_validator, validators.RegexValidator))
     self.assertTrue(regex_validator.inverse_match, )
示例#5
0
 def test_field_tags_required(self):
     form = tm_forms.TaskForm()
     self.assertFalse(form.fields['tags'].required)
示例#6
0
 def test_field_tags_help_text(self):
     form = tm_forms.TaskForm()
     self.assertEquals(form.fields['tags'].help_text,
                       'Separate each tag by "|"')
示例#7
0
 def test_field_tags_type(self):
     form = tm_forms.TaskForm()
     self.assertTrue(form.fields['tags'], forms.CharField)
示例#8
0
 def test_field_assigned_to_queryset(self):
     form = tm_forms.TaskForm()
     self.assertEquals(len(form.fields['assigned_to'].queryset), 2)
     self.assertEquals(set(form.fields['assigned_to'].queryset),
                       {self.ivanov, self.petrov})
示例#9
0
 def test_field_creator_queryset(self):
     form = tm_forms.TaskForm()
     self.assertEquals(len(form.fields['creator'].queryset), 2)
     self.assertEquals(set(form.fields['creator'].queryset),
                       {self.ivanov, self.petrov})
示例#10
0
 def test_form_model(self):
     form = tm_forms.TaskForm()
     self.assertEquals(form.Meta().model, tm_models.Task)
示例#11
0
 def test_form_fields(self):
     form = tm_forms.TaskForm()
     self.assertEquals(form.Meta().fields,
                       ('name', 'description', 'status', 'creator',
                        'assigned_to', 'tags'))