Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 2, 2024
1 parent 5096772 commit 1ce9dae
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 37 deletions.
18 changes: 9 additions & 9 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -72,31 +72,31 @@ def learner_and_oauth2(learner):
)


@pytest.fixture()
@pytest.fixture
def staff_user(db): # noqa: ARG001
"""Staff user fixture"""
from mitol.common.factories import UserFactory

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()
client.force_login(learner)
return client


@pytest.fixture()
@pytest.fixture
def staff_client(staff_user):
"""Django test client that is authenticated with the staff user"""
client = Client()
client.force_login(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"
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion tests/mitol/authentication/views/test_djoser.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
EMAIL = "[email protected]"


@pytest.fixture()
@pytest.fixture
def user():
from mitol.common.factories import UserFactory

Expand Down
2 changes: 1 addition & 1 deletion tests/mitol/digitalcredentials/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion tests/mitol/geoip/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
fake = faker.Factory.create()


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.parametrize(
"v4,in_block", # noqa: PT006
[
Expand Down
4 changes: 2 additions & 2 deletions tests/mitol/google_sheets/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/mitol/google_sheets/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/mitol/google_sheets_deferrals/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions tests/mitol/google_sheets_refunds/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down
20 changes: 10 additions & 10 deletions tests/mitol/hubspot_api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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()
Expand All @@ -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"
Expand All @@ -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()
Expand Down Expand Up @@ -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
):
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion tests/mitol/mail/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/mitol/payment_gateway/api/test_cybersource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 1ce9dae

Please sign in to comment.