From 1ce9daed7b113c13e9a3a863ddf164bea8d66cb6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 22:46:33 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/conftest.py | 18 ++++++++--------- .../mitol/authentication/views/test_djoser.py | 2 +- .../mitol/digitalcredentials/test_backend.py | 2 +- tests/mitol/geoip/test_api.py | 2 +- tests/mitol/google_sheets/test_api.py | 4 ++-- tests/mitol/google_sheets/test_views.py | 4 ++-- .../mitol/google_sheets_deferrals/test_api.py | 6 +++--- tests/mitol/google_sheets_refunds/test_api.py | 6 +++--- tests/mitol/hubspot_api/test_api.py | 20 +++++++++---------- tests/mitol/mail/test_api.py | 2 +- .../payment_gateway/api/test_cybersource.py | 8 ++++---- 11 files changed, 37 insertions(+), 37 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 75951738..2c3a0b44 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -26,7 +26,7 @@ def django_db_modify_db_settings_parallel_suffix( # noqa: PT004 skip_if_no_django() -@pytest.fixture() +@pytest.fixture def learner_drf_client(learner): """DRF API test client that is authenticated with the user""" # import is here to avoid trying to load django before settings are initialized @@ -37,7 +37,7 @@ def learner_drf_client(learner): return client -@pytest.fixture() +@pytest.fixture def learner(db): # noqa: ARG001 """Fixture for a default learner""" # import is here to avoid trying to load django before settings are initialized @@ -46,7 +46,7 @@ def learner(db): # noqa: ARG001 return UserFactory.create() -@pytest.fixture() +@pytest.fixture def learner_and_oauth2(learner): """Fixture for a default learner and oauth2 records""" # import is here to avoid trying to load django before settings are initialized @@ -72,7 +72,7 @@ def learner_and_oauth2(learner): ) -@pytest.fixture() +@pytest.fixture def staff_user(db): # noqa: ARG001 """Staff user fixture""" from mitol.common.factories import UserFactory @@ -80,7 +80,7 @@ def staff_user(db): # noqa: ARG001 return UserFactory.create(is_staff=True) -@pytest.fixture() +@pytest.fixture def user_client(learner): """Django test client that is authenticated with the user""" client = Client() @@ -88,7 +88,7 @@ def user_client(learner): return client -@pytest.fixture() +@pytest.fixture def staff_client(staff_user): """Django test client that is authenticated with the staff user""" client = Client() @@ -96,7 +96,7 @@ def staff_client(staff_user): return client -@pytest.fixture() +@pytest.fixture def google_sheets_base_settings(settings): """Fixture for base google sheets settings""" settings.MITOL_GOOGLE_SHEETS_ENROLLMENT_CHANGE_SHEET_ID = "1" @@ -106,14 +106,14 @@ def google_sheets_base_settings(settings): return settings -@pytest.fixture() +@pytest.fixture def google_sheets_service_creds_settings(settings): """Fixture for google sheets settings configured for a service account""" settings.MITOL_GOOGLE_SHEETS_DRIVE_SERVICE_ACCOUNT_CREDS = '{"credentials": "json"}' return settings -@pytest.fixture() +@pytest.fixture def google_sheets_client_creds_settings(settings): """Fixture gor google sheets settings configured with OAuth""" settings.MITOL_GOOGLE_SHEETS_DRIVE_CLIENT_ID = "nhijg1i.apps.googleusercontent.com" diff --git a/tests/mitol/authentication/views/test_djoser.py b/tests/mitol/authentication/views/test_djoser.py index 6acd178d..20a02e8b 100644 --- a/tests/mitol/authentication/views/test_djoser.py +++ b/tests/mitol/authentication/views/test_djoser.py @@ -9,7 +9,7 @@ EMAIL = "email@example.com" -@pytest.fixture() +@pytest.fixture def user(): from mitol.common.factories import UserFactory diff --git a/tests/mitol/digitalcredentials/test_backend.py b/tests/mitol/digitalcredentials/test_backend.py index 42121eec..9c4cbc5a 100644 --- a/tests/mitol/digitalcredentials/test_backend.py +++ b/tests/mitol/digitalcredentials/test_backend.py @@ -30,7 +30,7 @@ def test_build_api_url_invalid(settings): build_api_url("/path") -@pytest.mark.django_db() +@pytest.mark.django_db def test_create_deep_link_url(settings): """Test create_deep_link_url()""" settings.MITOL_DIGITAL_CREDENTIALS_AUTH_TYPE = "test_auth_type" diff --git a/tests/mitol/geoip/test_api.py b/tests/mitol/geoip/test_api.py index 5c4f21b2..0317fb32 100644 --- a/tests/mitol/geoip/test_api.py +++ b/tests/mitol/geoip/test_api.py @@ -12,7 +12,7 @@ fake = faker.Factory.create() -@pytest.mark.django_db() +@pytest.mark.django_db @pytest.mark.parametrize( "v4,in_block", # noqa: PT006 [ diff --git a/tests/mitol/google_sheets/test_api.py b/tests/mitol/google_sheets/test_api.py index 055cd03e..10496ce6 100644 --- a/tests/mitol/google_sheets/test_api.py +++ b/tests/mitol/google_sheets/test_api.py @@ -8,7 +8,7 @@ from mitol.google_sheets.factories import GoogleApiAuthFactory -@pytest.mark.django_db() +@pytest.mark.django_db def test_get_credentials_service_account(mocker, settings): """ get_credentials should construct a valid Credentials object from app settings using Service Account auth @@ -35,7 +35,7 @@ def test_get_credentials_service_account(mocker, settings): assert creds == patched_svc_account_creds.from_service_account_info.return_value -@pytest.mark.django_db() +@pytest.mark.django_db def test_get_credentials_personal_auth(settings): """ get_credentials should construct a valid Credentials object from data and app settings using personal diff --git a/tests/mitol/google_sheets/test_views.py b/tests/mitol/google_sheets/test_views.py index f5c668e5..abce44f7 100644 --- a/tests/mitol/google_sheets/test_views.py +++ b/tests/mitol/google_sheets/test_views.py @@ -13,7 +13,7 @@ lazy = lazy_fixture -@pytest.fixture() +@pytest.fixture def google_api_auth(learner): """Fixture that creates a google auth object""" return GoogleApiAuthFactory.create(requesting_user=learner) @@ -53,7 +53,7 @@ def test_request_auth(mocker, settings, staff_client): @pytest.mark.parametrize("existing_auth", [lazy("google_api_auth"), None]) -@pytest.mark.django_db() +@pytest.mark.django_db def test_complete_auth(mocker, settings, learner, existing_auth): # noqa: ARG001 """ View that handles Google auth completion should fetch a token and save/update a diff --git a/tests/mitol/google_sheets_deferrals/test_api.py b/tests/mitol/google_sheets_deferrals/test_api.py index 524cf908..9d3c61fc 100644 --- a/tests/mitol/google_sheets_deferrals/test_api.py +++ b/tests/mitol/google_sheets_deferrals/test_api.py @@ -14,7 +14,7 @@ from pytest_lazyfixture import lazy_fixture -@pytest.fixture() +@pytest.fixture def request_csv_rows(settings): """Fake deferral request spreadsheet data rows (loaded from CSV)""" fake_request_csv_filepath = os.path.join( # noqa: PTH118 @@ -25,7 +25,7 @@ def request_csv_rows(settings): return [line.split(",") for i, line in enumerate(f.readlines()) if i > 0] -@pytest.fixture() +@pytest.fixture def pygsheets_fixtures(mocker, db, request_csv_rows): # noqa: ARG001 """Patched functions for pygsheets client functionality""" Mock = mocker.Mock @@ -60,7 +60,7 @@ def pygsheets_fixtures(mocker, db, request_csv_rows): # noqa: ARG001 ) -@pytest.fixture() +@pytest.fixture def google_sheets_deferral_settings(settings): settings.MITOL_GOOGLE_SHEETS_DEFERRALS_REQUEST_WORKSHEET_ID = "1" settings.MITOL_GOOGLE_SHEETS_DEFERRALS_PLUGINS = "app.plugins.DeferralPlugin" diff --git a/tests/mitol/google_sheets_refunds/test_api.py b/tests/mitol/google_sheets_refunds/test_api.py index 678c0083..2f6c02fa 100644 --- a/tests/mitol/google_sheets_refunds/test_api.py +++ b/tests/mitol/google_sheets_refunds/test_api.py @@ -14,7 +14,7 @@ from pytest_lazyfixture import lazy_fixture -@pytest.fixture() +@pytest.fixture def request_csv_rows(settings): """Fake refund request spreadsheet data rows (loaded from CSV)""" fake_request_csv_filepath = os.path.join( # noqa: PTH118 @@ -25,7 +25,7 @@ def request_csv_rows(settings): return [line.split(",") for i, line in enumerate(f.readlines()) if i > 0] -@pytest.fixture() +@pytest.fixture def pygsheets_fixtures(mocker, db, request_csv_rows): # noqa: ARG001 """Patched functions for pygsheets client functionality""" Mock = mocker.Mock @@ -60,7 +60,7 @@ def pygsheets_fixtures(mocker, db, request_csv_rows): # noqa: ARG001 ) -@pytest.fixture() +@pytest.fixture def google_sheets_refunds_settings(settings): settings.MITOL_GOOGLE_SHEETS_REFUNDS_REQUEST_WORKSHEET_ID = "1" settings.MITOL_GOOGLE_SHEETS_REFUNDS_PLUGINS = "app.plugins.RefundPlugin" diff --git a/tests/mitol/hubspot_api/test_api.py b/tests/mitol/hubspot_api/test_api.py index 6971101e..29bdf7b5 100644 --- a/tests/mitol/hubspot_api/test_api.py +++ b/tests/mitol/hubspot_api/test_api.py @@ -27,25 +27,25 @@ test_object_type = "deals" -@pytest.fixture() +@pytest.fixture def property_group(): """Return sample group JSON""" return {"name": "group_name", "label": "Group Label"} -@pytest.fixture() +@pytest.fixture def content_type_obj(): """Return a sample ContentType""" return ContentType.objects.get_for_model(Group) -@pytest.fixture() +@pytest.fixture def mock_hubspot_api(mocker): """Mock the send hubspot request method""" return mocker.patch("mitol.hubspot_api.api.HubspotApi") -@pytest.fixture() +@pytest.fixture def mock_search_object(mocker): """Return a mocked PublicObjectSearchRequest""" return mocker.patch("mitol.hubspot_api.api.PublicObjectSearchRequest") @@ -196,7 +196,7 @@ def test_delete_object_property(mock_hubspot_api, property_group): assert result == 204 # noqa: PLR2004 -@pytest.mark.django_db() +@pytest.mark.django_db def test_get_hubspot_id(): """Return the hubspot id if any for the specified content type and object ID""" hubspot_obj = HubspotObjectFactory.create() @@ -214,7 +214,7 @@ def test_format_app_id(settings, prefix): assert api.format_app_id(object_id) == f"{prefix}-{object_id}" -@pytest.mark.django_db() +@pytest.mark.django_db def test_upsert_object_request_new(mock_hubspot_api, content_type_obj): """A HubspotObject should be created after an object is synced for the first time""" hubspot_id = "123456789" @@ -234,7 +234,7 @@ def test_upsert_object_request_new(mock_hubspot_api, content_type_obj): ) -@pytest.mark.django_db() +@pytest.mark.django_db def test_upsert_object_request_exists(mock_hubspot_api): """upsert_object_request should try a patch hubspot API call if there's an existing Hubspot object""" # noqa: E501 hs_obj = HubspotObjectFactory.create() @@ -264,7 +264,7 @@ def test_upsert_object_request_exists(mock_hubspot_api): api.HubspotObjectType.CONTACTS.value, ], ) -@pytest.mark.django_db() +@pytest.mark.django_db def test_upsert_object_request_missing_id( # noqa: PLR0913 mocker, mock_hubspot_api, content_type_obj, status, message, hs_type ): @@ -303,7 +303,7 @@ def test_upsert_object_request_missing_id( # noqa: PLR0913 ) -@pytest.mark.django_db() +@pytest.mark.django_db def test_upsert_object_request_other_error(mocker, mock_hubspot_api, content_type_obj): """If a non-dupe ApIException happens, raise it""" object_id = 123 @@ -330,7 +330,7 @@ def test_upsert_object_request_other_error(mocker, mock_hubspot_api, content_typ @pytest.mark.parametrize("is_primary_email", [True, False]) -@pytest.mark.django_db() +@pytest.mark.django_db def test_upsert_object_contact_dupe_email(mocker, mock_hubspot_api, is_primary_email): """If single hubspot contact has multiple emails matching 2+ django users, delete the other email""" # noqa: E501 dupe_hubspot_id = "123456789" diff --git a/tests/mitol/mail/test_api.py b/tests/mitol/mail/test_api.py index 3293f238..4bdaf452 100644 --- a/tests/mitol/mail/test_api.py +++ b/tests/mitol/mail/test_api.py @@ -19,7 +19,7 @@ User = get_user_model() -@pytest.fixture() +@pytest.fixture def email_settings(settings): # noqa: PT004 """Default settings for email tests""" # noqa: D401 settings.MITOL_MAIL_RECIPIENT_OVERRIDE = None diff --git a/tests/mitol/payment_gateway/api/test_cybersource.py b/tests/mitol/payment_gateway/api/test_cybersource.py index 8fae2109..e5249137 100644 --- a/tests/mitol/payment_gateway/api/test_cybersource.py +++ b/tests/mitol/payment_gateway/api/test_cybersource.py @@ -29,22 +29,22 @@ ISO_8601_FORMAT = "%Y-%m-%dT%H:%M:%SZ" -@pytest.fixture() +@pytest.fixture def order(): return OrderFactory() -@pytest.fixture() +@pytest.fixture def refund(): return RefundFactory() -@pytest.fixture() +@pytest.fixture def cartitems(): return CartItemFactory.create_batch(5) -@pytest.fixture() +@pytest.fixture def response_payload(request): """Fixture to return dictionary of a specific JSON file with provided name in request param""" # noqa: E501