def test_clean_username_no_user(self): data = {'username': '******', 'password': self.good_user.password} form = LoginForm(data=data) self.assertFalse(form.is_valid()) form.cleaned_data = data with self.assertRaises(forms.ValidationError) as e: form.clean_username() self.assertEqual(e.exception.message, "Niepoprawny użytkownik")
def test_clean_username(self): data = { 'username': self.good_user.username, 'password': self.good_user.password } form = LoginForm(data=data) self.assertTrue(form.is_valid()) self.assertEqual(self.good_user.username, form.clean_username())