def test_nickname_in_use(self): # SETUP expected = False expected_error_count = 1 expected_error_message = [u'This nickname is already taken. Please choose another.'] data = { 'nickname': 'harp' } form = PlayerForm(data = data) # CALL actual = form.is_valid() # ASSERT self.assertEqual(expected, actual) self.assertEqual(expected_error_count, len(form._errors)) self.assertEqual(expected_error_message, form._errors['nickname'])
def test_nickname_missing(self): # SETUP expected = False expected_error_count = 1 expected_error_message = [u'This field is required.'] data = { 'nickname': None } form = PlayerForm(data = data) # CALL actual = form.is_valid() # ASSERT self.assertEqual(expected, actual) self.assertEqual(expected_error_count, len(form._errors)) self.assertEqual(expected_error_message, form._errors['nickname'])