Ejemplo n.º 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)
Ejemplo n.º 2
0
 def test_field_tags_instance_as_initial(self):
     form = tm_forms.TaskForm(instance=self.task)
     self.assertEquals(form.initial['tags'], 'task|test')
Ejemplo n.º 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)
Ejemplo n.º 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, )
Ejemplo n.º 5
0
 def test_field_tags_required(self):
     form = tm_forms.TaskForm()
     self.assertFalse(form.fields['tags'].required)
Ejemplo n.º 6
0
 def test_field_tags_help_text(self):
     form = tm_forms.TaskForm()
     self.assertEquals(form.fields['tags'].help_text,
                       'Separate each tag by "|"')
Ejemplo n.º 7
0
 def test_field_tags_type(self):
     form = tm_forms.TaskForm()
     self.assertTrue(form.fields['tags'], forms.CharField)
Ejemplo n.º 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})
Ejemplo n.º 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})
Ejemplo n.º 10
0
 def test_form_model(self):
     form = tm_forms.TaskForm()
     self.assertEquals(form.Meta().model, tm_models.Task)
Ejemplo n.º 11
0
 def test_form_fields(self):
     form = tm_forms.TaskForm()
     self.assertEquals(form.Meta().fields,
                       ('name', 'description', 'status', 'creator',
                        'assigned_to', 'tags'))