def test_task_create_form_not_valid_data(self): """ TaskForm test send not valid data """ # get tasks list page form_data = { 'user': "******", 'title': "T", 'description': "De", 'status': " " } form = TaskForm(data=form_data) # test if form is not valid self.assertFalse(form.is_valid()) self.assertIn(u'Select a valid choice. ' u'That choice is not one of the available choices.', str(form['user'].errors)) self.assertIn(u'Ensure this value has at' u' least 3 characters (it has 1).', str(form['title'].errors)) self.assertIn(u'Ensure this value has at' u' least 3 characters (it has 2)', str(form['description'].errors)) self.assertIn(u'Select a valid choice. ' u'is not one of the available choices.', str(form['status'].errors))
def test_valid_task_create_form(self): """ Create task """ form_data = { 'user': 1, 'title': "Title", 'description': "Description", 'status': 1 } form = TaskForm(data=form_data) # test if form is not valid self.assertTrue(form.is_valid())
def test_task_create_form_no_data(self): """ TaskForm test send no data """ form_data = {} form = TaskForm(data=form_data) # test if form is not valid self.assertFalse(form.is_valid()) self.assertIn(u'This field is required', str(form['user'].errors)) self.assertIn(u'This field is required', str(form['title'].errors)) self.assertIn(u'This field is required', str(form['description'].errors)) self.assertIn(u'This field is required', str(form['status'].errors))