logging: Remove unncessary logging patches in backend tests.

There were some tests that had mock patches for logging, although no
logging was actually happening there. This commit removes such patches
in `corporate/tests/test_stripe.py`, `zerver/tests/test_cache.py`,
`zerver/tests/test_queue_worker.py`,
and `zerver/tests/test_signup.py`.
This commit is contained in:
m-e-l-u-h-a-n 2020-12-08 13:55:42 +05:30 committed by Tim Abbott
parent c2e3d626e2
commit 7417ac9165
4 changed files with 11 additions and 18 deletions

View File

@ -1674,8 +1674,7 @@ class StripeTest(StripeTestCase):
self.assertIsNone(plan.next_invoice_date) self.assertIsNone(plan.next_invoice_date)
self.assertEqual(plan.status, CustomerPlan.ENDED) self.assertEqual(plan.status, CustomerPlan.ENDED)
@patch("corporate.lib.stripe.billing_logger.info") def test_downgrade_free_trial(self) -> None:
def test_downgrade_free_trial(self, mock_: Mock) -> None:
user = self.example_user("hamlet") user = self.example_user("hamlet")
free_trial_end_date = self.now + timedelta(days=60) free_trial_end_date = self.now + timedelta(days=60)
@ -1757,8 +1756,7 @@ class StripeTest(StripeTestCase):
self.assertEqual(old_plan.next_invoice_date, None) self.assertEqual(old_plan.next_invoice_date, None)
self.assertEqual(old_plan.status, CustomerPlan.ENDED) self.assertEqual(old_plan.status, CustomerPlan.ENDED)
@patch("corporate.lib.stripe.billing_logger.info") def test_deactivate_realm(self) -> None:
def test_deactivate_realm(self, mock_: Mock) -> None:
user = self.example_user("hamlet") user = self.example_user("hamlet")
with patch("corporate.lib.stripe.timezone_now", return_value=self.now): with patch("corporate.lib.stripe.timezone_now", return_value=self.now):
self.local_upgrade(self.seat_count, True, CustomerPlan.ANNUAL, 'token') self.local_upgrade(self.seat_count, True, CustomerPlan.ANNUAL, 'token')
@ -1801,8 +1799,7 @@ class StripeTest(StripeTestCase):
invoice_plans_as_needed(self.next_year) invoice_plans_as_needed(self.next_year)
mocked.assert_not_called() mocked.assert_not_called()
@patch("corporate.lib.stripe.billing_logger.info") def test_reupgrade_by_billing_admin_after_realm_deactivation(self) -> None:
def test_reupgrade_by_billing_admin_after_realm_deactivation(self, mock_: Mock) -> None:
user = self.example_user("hamlet") user = self.example_user("hamlet")
with patch("corporate.lib.stripe.timezone_now", return_value=self.now): with patch("corporate.lib.stripe.timezone_now", return_value=self.now):

View File

@ -177,10 +177,8 @@ class GetCacheWithKeyDecoratorTest(ZulipTestCase):
return return
hamlet = self.example_user('hamlet') hamlet = self.example_user('hamlet')
with patch('zerver.lib.cache.logger.warning') as mock_warn: with self.assertRaises(NotFoundInCache):
with self.assertRaises(NotFoundInCache): get_user_function_with_good_cache_keys(hamlet.id)
get_user_function_with_good_cache_keys(hamlet.id)
mock_warn.assert_not_called()
cache_set(good_cache_key_function(hamlet.id), hamlet) cache_set(good_cache_key_function(hamlet.id), hamlet)
result = get_user_function_with_good_cache_keys(hamlet.id) result = get_user_function_with_good_cache_keys(hamlet.id)

View File

@ -424,8 +424,7 @@ class WorkerTest(ZulipTestCase):
worker.setup() worker.setup()
with patch('zerver.lib.actions.send_email'), \ with patch('zerver.lib.actions.send_email'), \
patch('zerver.worker.queue_processors.send_future_email') \ patch('zerver.worker.queue_processors.send_future_email') \
as send_mock, \ as send_mock:
patch('logging.info'):
worker.start() worker.start()
self.assertEqual(send_mock.call_count, 2) self.assertEqual(send_mock.call_count, 2)

View File

@ -556,12 +556,11 @@ class PasswordResetTest(ZulipTestCase):
# If the domain doesn't match, we do generate an email # If the domain doesn't match, we do generate an email
with self.settings(LDAP_APPEND_DOMAIN="example.com"): with self.settings(LDAP_APPEND_DOMAIN="example.com"):
email = self.example_email("hamlet") email = self.example_email("hamlet")
with patch('logging.info') as mock_logging: result = self.client_post('/accounts/password/reset/', {'email': email})
result = self.client_post('/accounts/password/reset/', {'email': email}) self.assertEqual(result.status_code, 302)
self.assertEqual(result.status_code, 302) self.assertTrue(result["Location"].endswith(
self.assertTrue(result["Location"].endswith( "/accounts/password/reset/done/"))
"/accounts/password/reset/done/")) result = self.client_get(result["Location"])
result = self.client_get(result["Location"])
body = self.get_reset_mail_body() body = self.get_reset_mail_body()
self.assertIn('reset your password', body) self.assertIn('reset your password', body)