示例#1
0
 def test_remove_empty_tag(self):
     data = {'title': 'some title',
             'body': 'some text',
             'form_tags': 't1, , ,,,'}
     form = AddQuestionForm(data)
     self.assertTrue(form.is_valid())
     self.assertEqual(form.cleaned_data['form_tags'], ['t1'])
示例#2
0
 def test_tags_clean(self):
     data = {'title': 'some title',
             'body': 'some text',
             'form_tags': '  T1  , t2'}
     form = AddQuestionForm(data)
     self.assertTrue(form.is_valid())
     self.assertEqual(form.cleaned_data['form_tags'], ['t1', 't2'])
示例#3
0
 def test_too_many_tags(self):
     data = {'title': 'some title',
             'body': 'some text',
             'form_tags': 't1,'*Question.TAGS_NUM}
     form = AddQuestionForm(data)
     self.assertTrue(form.is_valid())
     data = {'title': 'some title',
             'body': 'some text',
             'form_tags': 't1,'*(Question.TAGS_NUM + 1)}
     form = AddQuestionForm(data)
     self.assertFalse(form.is_valid())
示例#4
0
 def test_empty_form(self):
     form = AddQuestionForm({})
     self.assertFalse(form.is_valid())
示例#5
0
 def test_empty_tags(self):
     data = {'title': 'some title',
             'body': 'some text',
             'form_tags': ''}
     form = AddQuestionForm(data)
     self.assertFalse(form.is_valid())
示例#6
0
 def test_valid_form(self):
     data = {'title': 'some title',
             'body': 'some text',
             'form_tags': 't1'}
     form = AddQuestionForm(data)
     self.assertTrue(form.is_valid())