fix tests

This commit is contained in:
virusdefender
2019-03-26 10:51:49 +08:00
parent abfe99a8bf
commit f2576a9411
5 changed files with 13 additions and 10 deletions

View File

@@ -304,7 +304,7 @@ class TwoFactorAuthAPITest(APITestCase):
self.assertEqual(user.two_factor_auth, False)
@mock.patch("account.views.oj.send_email_async.delay")
@mock.patch("account.views.oj.send_email_async.send")
class ApplyResetPasswordAPITest(CaptchaTest):
def setUp(self):
self.create_user("test", "test123", login=False)
@@ -317,20 +317,20 @@ class ApplyResetPasswordAPITest(CaptchaTest):
def _refresh_captcha(self):
self.data["captcha"] = self._set_captcha(self.client.session)
def test_apply_reset_password(self, send_email_delay):
def test_apply_reset_password(self, send_email_send):
resp = self.client.post(self.url, data=self.data)
self.assertSuccess(resp)
send_email_delay.assert_called()
send_email_send.assert_called()
def test_apply_reset_password_twice_in_20_mins(self, send_email_delay):
def test_apply_reset_password_twice_in_20_mins(self, send_email_send):
self.test_apply_reset_password()
send_email_delay.reset_mock()
send_email_send.reset_mock()
self._refresh_captcha()
resp = self.client.post(self.url, data=self.data)
self.assertDictEqual(resp.data, {"error": "error", "data": "You can only reset password once per 20 minutes"})
send_email_delay.assert_not_called()
send_email_send.assert_not_called()
def test_apply_reset_password_again_after_20_mins(self, send_email_delay):
def test_apply_reset_password_again_after_20_mins(self, send_email_send):
self.test_apply_reset_password()
user = User.objects.first()
user.reset_password_token_expire_time = now() - timedelta(minutes=21)