def test_form_good_data(self): params = {"username": self.user.username} request = MockRequest(self.user) form = DeleteAccountForm(request, data=params) self.assertTrue(form.is_valid()) form.save() self.assertEqual(request.user, AnonymousUser()) messages = list(request._messages) self.assertEqual(str(messages[0]), "Account deleted. Thanks for using our service.")
def test_form_bad_data(self): params = {"username": "******" + self.user.username} request = MockRequest(self.user) form = DeleteAccountForm(request, data=params) self.assertFalse(form.is_valid())