From 4bcfba728e15750659d758d0f61bbda39968b4f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Sun, 1 Mar 2020 22:30:12 +0200 Subject: [PATCH] Use unittest.mock --- hc/accounts/tests/test_close_account.py | 3 ++- hc/accounts/tests/test_pruneusers.py | 2 +- hc/accounts/tests/test_senddeletionnotices.py | 2 +- hc/accounts/tests/test_unsubscribe_reports.py | 2 +- hc/api/tests/test_check_model.py | 2 +- hc/api/tests/test_notify.py | 2 +- hc/api/tests/test_prunepingsslow.py | 2 +- hc/api/tests/test_sendalerts.py | 2 +- hc/api/tests/test_sendreports.py | 2 +- hc/front/tests/test_add_discord_complete.py | 2 +- hc/front/tests/test_add_matrix.py | 3 ++- hc/front/tests/test_add_pushbullet_complete.py | 2 +- hc/front/tests/test_add_slack_complete.py | 2 +- hc/front/tests/test_add_telegram.py | 3 ++- hc/front/tests/test_cron_preview.py | 2 +- hc/front/tests/test_send_test_notification.py | 2 +- hc/front/tests/test_trello_settings.py | 2 +- hc/front/tests/test_unsubscribe_email.py | 3 ++- hc/payments/tests/test_address.py | 2 +- hc/payments/tests/test_billing_history.py | 2 +- hc/payments/tests/test_get_client_token.py | 2 +- hc/payments/tests/test_payment_method.py | 2 +- hc/payments/tests/test_update_subscription.py | 2 +- 23 files changed, 27 insertions(+), 23 deletions(-) diff --git a/hc/accounts/tests/test_close_account.py b/hc/accounts/tests/test_close_account.py index fe927dd5..e83fb827 100644 --- a/hc/accounts/tests/test_close_account.py +++ b/hc/accounts/tests/test_close_account.py @@ -1,8 +1,9 @@ +from unittest.mock import patch + from django.contrib.auth.models import User from hc.api.models import Check from hc.payments.models import Subscription from hc.test import BaseTestCase -from mock import patch class CloseAccountTestCase(BaseTestCase): diff --git a/hc/accounts/tests/test_pruneusers.py b/hc/accounts/tests/test_pruneusers.py index b18746ec..09fe5060 100644 --- a/hc/accounts/tests/test_pruneusers.py +++ b/hc/accounts/tests/test_pruneusers.py @@ -1,4 +1,5 @@ from datetime import timedelta +from unittest.mock import Mock from django.contrib.auth.models import User from django.utils import timezone @@ -6,7 +7,6 @@ from hc.accounts.management.commands.pruneusers import Command from hc.accounts.models import Project from hc.api.models import Check from hc.test import BaseTestCase -from mock import Mock class PruneUsersTestCase(BaseTestCase): diff --git a/hc/accounts/tests/test_senddeletionnotices.py b/hc/accounts/tests/test_senddeletionnotices.py index 0187622a..79f5800c 100644 --- a/hc/accounts/tests/test_senddeletionnotices.py +++ b/hc/accounts/tests/test_senddeletionnotices.py @@ -1,4 +1,5 @@ from datetime import timedelta as td +from unittest.mock import Mock from django.core import mail from django.utils.timezone import now @@ -6,7 +7,6 @@ from hc.accounts.management.commands.senddeletionnotices import Command from hc.accounts.models import Member from hc.api.models import Check, Ping from hc.test import BaseTestCase -from mock import Mock class SendDeletionNoticesTestCase(BaseTestCase): diff --git a/hc/accounts/tests/test_unsubscribe_reports.py b/hc/accounts/tests/test_unsubscribe_reports.py index 1213e4f5..4b43de84 100644 --- a/hc/accounts/tests/test_unsubscribe_reports.py +++ b/hc/accounts/tests/test_unsubscribe_reports.py @@ -1,10 +1,10 @@ from datetime import timedelta as td import time +from unittest.mock import patch from django.core import signing from django.utils.timezone import now from hc.test import BaseTestCase -from mock import patch class UnsubscribeReportsTestCase(BaseTestCase): diff --git a/hc/api/tests/test_check_model.py b/hc/api/tests/test_check_model.py index 8b74067b..c279b9ff 100644 --- a/hc/api/tests/test_check_model.py +++ b/hc/api/tests/test_check_model.py @@ -1,9 +1,9 @@ from datetime import datetime, timedelta +from unittest.mock import patch from django.utils import timezone from hc.api.models import Check, Flip from hc.test import BaseTestCase -from mock import patch class CheckModelTestCase(BaseTestCase): diff --git a/hc/api/tests/test_notify.py b/hc/api/tests/test_notify.py index ad1617ac..b804c054 100644 --- a/hc/api/tests/test_notify.py +++ b/hc/api/tests/test_notify.py @@ -2,12 +2,12 @@ from datetime import timedelta as td import json +from unittest.mock import patch, Mock from django.core import mail from django.utils.timezone import now from hc.api.models import Channel, Check, Notification from hc.test import BaseTestCase -from mock import patch, Mock from requests.exceptions import ConnectionError, Timeout from django.test.utils import override_settings diff --git a/hc/api/tests/test_prunepingsslow.py b/hc/api/tests/test_prunepingsslow.py index fca88663..fb0f3a25 100644 --- a/hc/api/tests/test_prunepingsslow.py +++ b/hc/api/tests/test_prunepingsslow.py @@ -1,10 +1,10 @@ from datetime import timedelta +from unittest.mock import Mock from django.utils import timezone from hc.api.management.commands.prunepingsslow import Command from hc.api.models import Check, Ping from hc.test import BaseTestCase -from mock import Mock class PrunePingsSlowTestCase(BaseTestCase): diff --git a/hc/api/tests/test_sendalerts.py b/hc/api/tests/test_sendalerts.py index 95ab009b..b8d560a0 100644 --- a/hc/api/tests/test_sendalerts.py +++ b/hc/api/tests/test_sendalerts.py @@ -1,6 +1,6 @@ from datetime import timedelta as td from io import StringIO -from mock import Mock, patch +from unittest.mock import Mock, patch from django.core.management import call_command from django.utils.timezone import now diff --git a/hc/api/tests/test_sendreports.py b/hc/api/tests/test_sendreports.py index 94590d1b..bbd791fb 100644 --- a/hc/api/tests/test_sendreports.py +++ b/hc/api/tests/test_sendreports.py @@ -1,11 +1,11 @@ from datetime import timedelta as td +from unittest.mock import Mock from django.core import mail from django.utils.timezone import now from hc.api.management.commands.sendreports import Command from hc.api.models import Check from hc.test import BaseTestCase -from mock import Mock class SendReportsTestCase(BaseTestCase): diff --git a/hc/front/tests/test_add_discord_complete.py b/hc/front/tests/test_add_discord_complete.py index 68f8c013..ab88295d 100644 --- a/hc/front/tests/test_add_discord_complete.py +++ b/hc/front/tests/test_add_discord_complete.py @@ -1,9 +1,9 @@ import json +from unittest.mock import patch from django.test.utils import override_settings from hc.api.models import Channel from hc.test import BaseTestCase -from mock import patch @override_settings(DISCORD_CLIENT_ID="t1", DISCORD_CLIENT_SECRET="s1") diff --git a/hc/front/tests/test_add_matrix.py b/hc/front/tests/test_add_matrix.py index df9c0711..fe729c94 100644 --- a/hc/front/tests/test_add_matrix.py +++ b/hc/front/tests/test_add_matrix.py @@ -1,7 +1,8 @@ +from unittest.mock import patch + from django.test.utils import override_settings from hc.api.models import Channel from hc.test import BaseTestCase -from mock import patch @override_settings(MATRIX_ACCESS_TOKEN="foo") diff --git a/hc/front/tests/test_add_pushbullet_complete.py b/hc/front/tests/test_add_pushbullet_complete.py index 8214bff9..10ab3424 100644 --- a/hc/front/tests/test_add_pushbullet_complete.py +++ b/hc/front/tests/test_add_pushbullet_complete.py @@ -1,9 +1,9 @@ import json +from unittest.mock import patch from django.test.utils import override_settings from hc.api.models import Channel from hc.test import BaseTestCase -from mock import patch @override_settings(PUSHBULLET_CLIENT_ID="t1", PUSHBULLET_CLIENT_SECRET="s1") diff --git a/hc/front/tests/test_add_slack_complete.py b/hc/front/tests/test_add_slack_complete.py index 4c805873..9faba654 100644 --- a/hc/front/tests/test_add_slack_complete.py +++ b/hc/front/tests/test_add_slack_complete.py @@ -1,9 +1,9 @@ import json +from unittest.mock import patch from django.test.utils import override_settings from hc.api.models import Channel from hc.test import BaseTestCase -from mock import patch @override_settings(SLACK_CLIENT_ID="fake-client-id") diff --git a/hc/front/tests/test_add_telegram.py b/hc/front/tests/test_add_telegram.py index a4d3354a..c6a9463d 100644 --- a/hc/front/tests/test_add_telegram.py +++ b/hc/front/tests/test_add_telegram.py @@ -1,8 +1,9 @@ +from unittest.mock import patch + from django.core import signing from django.test.utils import override_settings from hc.api.models import Channel from hc.test import BaseTestCase -from mock import patch @override_settings(TELEGRAM_TOKEN="fake-token") diff --git a/hc/front/tests/test_cron_preview.py b/hc/front/tests/test_cron_preview.py index 0b226cdb..8882c0dd 100644 --- a/hc/front/tests/test_cron_preview.py +++ b/hc/front/tests/test_cron_preview.py @@ -1,7 +1,7 @@ from datetime import datetime +from unittest.mock import patch from hc.test import BaseTestCase -from mock import patch import pytz diff --git a/hc/front/tests/test_send_test_notification.py b/hc/front/tests/test_send_test_notification.py index 3732dd4b..7a4ceb94 100644 --- a/hc/front/tests/test_send_test_notification.py +++ b/hc/front/tests/test_send_test_notification.py @@ -1,9 +1,9 @@ import json +from unittest.mock import patch from django.core import mail from hc.api.models import Channel from hc.test import BaseTestCase -from mock import patch class SendTestNotificationTestCase(BaseTestCase): diff --git a/hc/front/tests/test_trello_settings.py b/hc/front/tests/test_trello_settings.py index cc7cd0ad..3e70725b 100644 --- a/hc/front/tests/test_trello_settings.py +++ b/hc/front/tests/test_trello_settings.py @@ -1,4 +1,4 @@ -from mock import patch +from unittest.mock import patch from django.test.utils import override_settings from hc.test import BaseTestCase diff --git a/hc/front/tests/test_unsubscribe_email.py b/hc/front/tests/test_unsubscribe_email.py index c9c2866b..4ec9ccf2 100644 --- a/hc/front/tests/test_unsubscribe_email.py +++ b/hc/front/tests/test_unsubscribe_email.py @@ -1,8 +1,9 @@ import time +from unittest.mock import patch + from django.core.signing import TimestampSigner from hc.api.models import Channel from hc.test import BaseTestCase -from mock import patch class UnsubscribeEmailTestCase(BaseTestCase): diff --git a/hc/payments/tests/test_address.py b/hc/payments/tests/test_address.py index 3333de6d..8ad82d10 100644 --- a/hc/payments/tests/test_address.py +++ b/hc/payments/tests/test_address.py @@ -1,4 +1,4 @@ -from mock import patch +from unittest.mock import patch from hc.payments.models import Subscription from hc.test import BaseTestCase diff --git a/hc/payments/tests/test_billing_history.py b/hc/payments/tests/test_billing_history.py index 3d758e53..a6f22566 100644 --- a/hc/payments/tests/test_billing_history.py +++ b/hc/payments/tests/test_billing_history.py @@ -1,4 +1,4 @@ -from mock import Mock, patch +from unittest.mock import Mock, patch from django.utils.timezone import now from hc.payments.models import Subscription diff --git a/hc/payments/tests/test_get_client_token.py b/hc/payments/tests/test_get_client_token.py index 4256902d..1094fde7 100644 --- a/hc/payments/tests/test_get_client_token.py +++ b/hc/payments/tests/test_get_client_token.py @@ -1,4 +1,4 @@ -from mock import patch +from unittest.mock import patch from hc.payments.models import Subscription from hc.test import BaseTestCase diff --git a/hc/payments/tests/test_payment_method.py b/hc/payments/tests/test_payment_method.py index f6a42064..71bb4f71 100644 --- a/hc/payments/tests/test_payment_method.py +++ b/hc/payments/tests/test_payment_method.py @@ -1,4 +1,4 @@ -from mock import patch +from unittest.mock import patch from hc.payments.models import Subscription from hc.test import BaseTestCase diff --git a/hc/payments/tests/test_update_subscription.py b/hc/payments/tests/test_update_subscription.py index da073405..5f20e85d 100644 --- a/hc/payments/tests/test_update_subscription.py +++ b/hc/payments/tests/test_update_subscription.py @@ -1,4 +1,4 @@ -from mock import patch +from unittest.mock import patch from hc.payments.models import Subscription from hc.test import BaseTestCase