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 Dec 23, 2024
1 parent ff1a6a2 commit f002c5e
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def mock_requests_get():


@pytest.fixture(autouse=True)
def prevent_requests(mocker, request): # noqa: PT004
def prevent_requests(mocker, request):
"""Patch requests to error on request by default"""
if "mocked_responses" in request.fixturenames:
return
Expand Down
16 changes: 8 additions & 8 deletions fixtures/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@


@pytest.fixture(autouse=True)
def silence_factory_logging(): # noqa: PT004
def silence_factory_logging():
"""Only show factory errors"""
logging.getLogger("factory").setLevel(logging.ERROR)


@pytest.fixture(autouse=True)
def warnings_as_errors(): # noqa: PT004
def warnings_as_errors():
"""
Convert warnings to errors. This should only affect unit tests, letting pylint and other plugins
raise DeprecationWarnings without erroring.
Expand Down Expand Up @@ -49,13 +49,13 @@ def warnings_as_errors(): # noqa: PT004
warnings.resetwarnings()


@pytest.fixture()
def randomness(): # noqa: PT004
@pytest.fixture
def randomness():
"""Ensure a fixed seed for factoryboy"""
factory.fuzzy.reseed_random("happy little clouds")


@pytest.fixture()
@pytest.fixture
def mocked_celery(mocker):
"""Mock object that patches certain celery functions"""
exception_class = TabError
Expand All @@ -73,20 +73,20 @@ def mocked_celery(mocker):
)


@pytest.fixture()
@pytest.fixture
def mock_context(mocker, user):
"""Mock context for serializers"""
return {"request": mocker.Mock(user=user)}


@pytest.fixture()
@pytest.fixture
def mocked_responses():
"""Mock responses fixture"""
with responses.RequestsMock() as rsps:
yield rsps


@pytest.fixture()
@pytest.fixture
def admin_drf_client(admin_user):
"""DRF API test client with admin user"""
client = APIClient()
Expand Down
18 changes: 9 additions & 9 deletions fixtures/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,34 @@
from unified_ecommerce.factories import UserFactory


@pytest.fixture()
@pytest.fixture
def user(db): # noqa: ARG001
"""Create a user"""
return UserFactory.create()


@pytest.fixture()
@pytest.fixture
def staff_user(db): # noqa: ARG001
"""Create a staff user"""
return UserFactory.create(is_staff=True)


@pytest.fixture()
@pytest.fixture
def logged_in_user(client, user):
"""Log the user in and yield the user object"""
client.force_login(user)
return user


@pytest.fixture()
@pytest.fixture
def logged_in_profile(client):
"""Add a Profile and logged-in User"""
user = UserFactory.create(username="george")
client.force_login(user)
return user.profile


@pytest.fixture()
@pytest.fixture
def jwt_token(db, user, client, rf, settings): # noqa: ARG001
"""Creates a JWT token for a regular user""" # noqa: D401
jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
Expand All @@ -50,31 +50,31 @@ def jwt_token(db, user, client, rf, settings): # noqa: ARG001
return token


@pytest.fixture()
@pytest.fixture
def client(db): # noqa: ARG001
"""
Similar to the builtin client but this provides the DRF client instead of the Django test client.
""" # noqa: E501
return APIClient()


@pytest.fixture()
@pytest.fixture
def user_client(user):
"""Version of the client that is authenticated with the user"""
client = APIClient()
client.force_authenticate(user=user)
return client


@pytest.fixture()
@pytest.fixture
def staff_client(staff_user):
"""Version of the client that is authenticated with the staff_user"""
client = APIClient()
client.force_authenticate(user=staff_user)
return client


@pytest.fixture()
@pytest.fixture
def profile_image():
"""Create a PNG image"""
image_file = BytesIO()
Expand Down
12 changes: 6 additions & 6 deletions payments/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@
pytestmark = [pytest.mark.django_db]


@pytest.fixture()
@pytest.fixture
def fulfilled_order():
"""Fixture for creating a fulfilled order"""
return OrderFactory.create(state=Order.STATE.FULFILLED)


@pytest.fixture()
@pytest.fixture
def fulfilled_transaction(fulfilled_order):
"""Fixture to creating a fulfilled transaction"""
payment_amount = 10.00
Expand All @@ -88,7 +88,7 @@ def fulfilled_transaction(fulfilled_order):
)


@pytest.fixture()
@pytest.fixture
def fulfilled_paypal_transaction(fulfilled_order):
"""Fixture to creating a fulfilled transaction"""
payment_amount = 10.00
Expand All @@ -114,7 +114,7 @@ def fulfilled_paypal_transaction(fulfilled_order):
)


@pytest.fixture()
@pytest.fixture
def fulfilled_complete_order():
"""Create a fulfilled order with line items."""

Expand All @@ -133,14 +133,14 @@ def fulfilled_complete_order():
return order


@pytest.fixture()
@pytest.fixture
def products():
"""Create products"""
with reversion.create_revision():
return ProductFactory.create_batch(5)


@pytest.fixture()
@pytest.fixture
def user(db):
"""Create a user"""
return UserFactory.create()
Expand Down
8 changes: 4 additions & 4 deletions payments/hooks/basket_add_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
FAKE = faker.Faker()


@pytest.fixture()
@pytest.fixture
def basket():
"""Create a basket."""
return BasketFactory.create()


@pytest.fixture()
@pytest.fixture
def maxmimd_resolvable_ip():
"""Create an IP, and then make sure there are mappings for it."""

Expand All @@ -43,7 +43,7 @@ def maxmimd_resolvable_ip():
)


@pytest.fixture()
@pytest.fixture
def user_client_and_basket():
"""Create a basket, and a user client with the basket's user."""

Expand Down Expand Up @@ -79,7 +79,7 @@ def mock_basket_add_hook_steps(mocker, exceptfor: str | None = None):
}


@pytest.fixture()
@pytest.fixture
def basket_add_hook_steps(mocker):
"""Mock the steps in the basket_add hook."""

Expand Down
2 changes: 1 addition & 1 deletion payments/hooks/post_sale_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
pytestmark = [pytest.mark.django_db]


@pytest.fixture()
@pytest.fixture
def pending_complete_order():
"""Create a pending order with line items."""

Expand Down
2 changes: 1 addition & 1 deletion unified_ecommerce/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_markdown_to_plain_text():
assert html_to_plain_text(normal_text) == normal_text


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.parametrize("chunk_size", [2, 3, 5, 7, 9, 10])
def test_prefetched_iterator(chunk_size):
"""
Expand Down

0 comments on commit f002c5e

Please sign in to comment.