Skip to content

Conversation

@robcsegal
Copy link
Contributor

@robcsegal robcsegal commented Dec 15, 2025

Added e2e tests for commerce order subscription

https://softwareone.atlassian.net/browse/MPT-14909

Summary by CodeRabbit

  • Tests

    • Added comprehensive end-to-end tests (sync + async) for order subscriptions covering CRUD, list/paginate, filter/select, not-found scenarios, and resilient teardown.
    • Added fixtures and a deterministic factory with frozen timestamp to produce repeatable subscription test data.
  • Chores

    • Test configuration updated with a new subscription line identifier used by e2e suites.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 15, 2025

Walkthrough

Adds a new e2e config key and introduces subscription-related pytest fixtures plus sync and async end-to-end tests for order subscription CRUD, listing, filtering, and teardown; includes a time-frozen factory producing deterministic subscription payloads.

Changes

Cohort / File(s) Summary
Configuration
e2e_config.test.json
Added top-level key commerce.agreement.subscription.line.id with value ALI-9850-2169-6098-0001.
Shared commerce fixtures
tests/e2e/commerce/conftest.py
Added fixtures: subscription_id(e2e_config), agreement_subscription_line_id(e2e_config), and invalid_subscription_id() to expose subscription identifiers for tests.
Order subscription factory
tests/e2e/commerce/order/subscription/conftest.py
Added order_subscription_factory(agreement_subscription_line_id) fixture returning a @freeze_time("2025-11-14T09:00:00.000Z") factory that builds deterministic subscription dicts (includes lines: [{"id": agreement_subscription_line_id}]).
Order subscription tests (async)
tests/e2e/commerce/order/subscription/test_async_subscription.py
Added async fixture created_order_subscription and multiple async tests for get-by-id, list/fetch_page, 404 not-found, filter/select (RQLQuery), create, update, and delete flows; includes async teardown with MPTAPIError handling and flaky markers.
Order subscription tests (sync)
tests/e2e/commerce/order/subscription/test_sync_subscription.py
Added sync fixture created_order_subscription and tests mirroring async coverage for CRUD, listing, filtering, and deletion with teardown handling MPT API errors.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay attention to fixture scopes and dependency wiring (e2e_config → agreement_subscription_line_id → order_subscription_factory → created_order_subscription).
  • Verify freezegun usage and resulting timestamps in payloads.
  • Review teardown logic for safe deletion and MPTAPIError handling.

Possibly related PRs

Suggested reviewers

  • jentyk
  • svazquezco
  • alephsur
  • ruben-sebrango

Poem

🐇 I hopped through configs, fixtures, and time,

Froze a moment so payloads align.
Subscriptions sprout, async and sync delight,
Cleanup at dusk, tests pass by moonlight.
— a rabbit, nibbling on green assertions.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and directly summarizes the main change: adding end-to-end tests for commerce order subscriptions, which aligns with all modified files.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch MPT-14909-add-e-2-e-tests-for-commerce-order-subscription

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3119766 and a47325a.

📒 Files selected for processing (5)
  • e2e_config.test.json (1 hunks)
  • tests/e2e/commerce/conftest.py (1 hunks)
  • tests/e2e/commerce/order/subscription/conftest.py (1 hunks)
  • tests/e2e/commerce/order/subscription/test_async_subscription.py (1 hunks)
  • tests/e2e/commerce/order/subscription/test_sync_subscription.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • e2e_config.test.json
  • tests/e2e/commerce/conftest.py
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-12-12T15:02:20.732Z
Learnt from: robcsegal
Repo: softwareone-platform/mpt-api-python-client PR: 160
File: tests/e2e/commerce/agreement/attachment/test_async_agreement_attachment.py:55-58
Timestamp: 2025-12-12T15:02:20.732Z
Learning: In pytest with pytest-asyncio, if a test function uses async fixtures but contains no await, declare the test function as def (synchronous) instead of async def. Pytest-asyncio will resolve the async fixtures automatically; this avoids linter complaints about unnecessary async functions. This pattern applies to any test file under the tests/ directory that uses such fixtures.

Applied to files:

  • tests/e2e/commerce/order/subscription/test_sync_subscription.py
  • tests/e2e/commerce/order/subscription/conftest.py
  • tests/e2e/commerce/order/subscription/test_async_subscription.py
📚 Learning: 2025-11-27T00:05:54.701Z
Learnt from: robcsegal
Repo: softwareone-platform/mpt-api-python-client PR: 131
File: tests/e2e/accounts/accounts_users/test_async_accounts_users.py:0-0
Timestamp: 2025-11-27T00:05:54.701Z
Learning: In pytest-asyncio, async fixtures are automatically resolved before being passed to test functions (both sync and async). Test functions receive the yielded value from async fixtures, not coroutines, so fixture parameters should never be awaited. A sync test function can use async fixtures without any special handling.

Applied to files:

  • tests/e2e/commerce/order/subscription/test_async_subscription.py
🧬 Code graph analysis (2)
tests/e2e/commerce/order/subscription/conftest.py (1)
tests/e2e/commerce/conftest.py (1)
  • agreement_subscription_line_id (60-61)
tests/e2e/commerce/order/subscription/test_async_subscription.py (6)
mpt_api_client/exceptions.py (1)
  • MPTAPIError (20-42)
mpt_api_client/rql/query_builder.py (1)
  • RQLQuery (115-524)
mpt_api_client/models/model.py (1)
  • id (119-121)
tests/e2e/conftest.py (1)
  • async_mpt_vendor (24-27)
tests/e2e/commerce/order/subscription/conftest.py (1)
  • order_subscription_factory (6-23)
tests/e2e/commerce/conftest.py (3)
  • order_id (15-16)
  • subscription_id (55-56)
  • invalid_subscription_id (65-66)
🪛 Ruff (0.14.8)
tests/e2e/commerce/order/subscription/test_sync_subscription.py

20-20: Unused noqa directive (unknown: WPS421)

Remove unused noqa directive

(RUF100)


42-42: Unused function argument: created_order_subscription

(ARG001)


53-53: Unused function argument: created_order_subscription

(ARG001)

tests/e2e/commerce/order/subscription/test_async_subscription.py

20-20: Unused noqa directive (unknown: WPS421)

Remove unused noqa directive

(RUF100)


44-44: Unused function argument: created_order_subscription

(ARG001)


55-55: Unused function argument: created_order_subscription

(ARG001)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (5)
tests/e2e/commerce/order/subscription/test_sync_subscription.py (2)

23-31: Well-structured fixture with proper teardown.

The fixture correctly manages subscription lifecycle with context manager pattern and error handling.


33-102: Comprehensive test coverage.

The test suite provides thorough coverage of CRUD operations, listing, filtering, and error handling. The static analysis warnings about unused created_order_subscription parameters are false positives—the fixture is required to ensure test isolation and that resources exist before operations.

tests/e2e/commerce/order/subscription/test_async_subscription.py (3)

23-33: Well-structured async fixture.

The async fixture properly uses the async context manager pattern for resource lifecycle management, consistent with the albertsola's suggestion.


79-83: Correct usage of synchronous test with async fixture.

This test function is correctly declared as def (synchronous) rather than async def, since it uses an async fixture but contains no await statements. This follows the pytest-asyncio pattern documented in the learnings.


35-103: Comprehensive async test coverage.

The async test suite mirrors the synchronous version with proper async/await patterns, async iteration (line 74), and error handling. The static analysis warnings about unused created_order_subscription parameters are false positives—the fixture ensures proper test setup and isolation.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

github-actions bot commented Dec 15, 2025

✅ Found Jira issue key in the title: MPT-14909

Generated by 🚫 dangerJS against a47325a

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (2)
tests/e2e/commerce/order/subscription/test_sync_subscription.py (1)

22-22: Remove unused noqa directive.

The WPS421 rule is not recognized by the current linter configuration. Remove the unused directive.

-        print(f"TEARDOWN - Unable to delete subscription: {getattr(error, 'title', str(error))}")  # noqa: WPS421
+        print(f"TEARDOWN - Unable to delete subscription: {getattr(error, 'title', str(error))}")
tests/e2e/commerce/order/subscription/test_async_subscription.py (1)

22-22: Remove unused noqa directive.

Same as the sync test file - the WPS421 rule is not recognized by the current linter configuration.

-        print(f"TEARDOWN - Unable to delete subscription: {getattr(error, 'title', str(error))}")  # noqa: WPS421
+        print(f"TEARDOWN - Unable to delete subscription: {getattr(error, 'title', str(error))}")
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0699809 and 642ea3a.

📒 Files selected for processing (5)
  • e2e_config.test.json (1 hunks)
  • tests/e2e/commerce/conftest.py (2 hunks)
  • tests/e2e/commerce/order/subscription/conftest.py (1 hunks)
  • tests/e2e/commerce/order/subscription/test_async_subscription.py (1 hunks)
  • tests/e2e/commerce/order/subscription/test_sync_subscription.py (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-12-12T15:02:20.732Z
Learnt from: robcsegal
Repo: softwareone-platform/mpt-api-python-client PR: 160
File: tests/e2e/commerce/agreement/attachment/test_async_agreement_attachment.py:55-58
Timestamp: 2025-12-12T15:02:20.732Z
Learning: In pytest with pytest-asyncio, if a test function uses async fixtures but contains no await, declare the test function as def (synchronous) instead of async def. Pytest-asyncio will resolve the async fixtures automatically; this avoids linter complaints about unnecessary async functions. This pattern applies to any test file under the tests/ directory that uses such fixtures.

Applied to files:

  • tests/e2e/commerce/conftest.py
  • tests/e2e/commerce/order/subscription/test_async_subscription.py
  • tests/e2e/commerce/order/subscription/conftest.py
  • tests/e2e/commerce/order/subscription/test_sync_subscription.py
🧬 Code graph analysis (2)
tests/e2e/commerce/order/subscription/conftest.py (1)
tests/e2e/commerce/conftest.py (2)
  • agreement_subscription_line_id (61-62)
  • factory (73-94)
tests/e2e/commerce/order/subscription/test_sync_subscription.py (5)
mpt_api_client/exceptions.py (1)
  • MPTAPIError (20-42)
mpt_api_client/rql/query_builder.py (1)
  • RQLQuery (115-524)
tests/e2e/conftest.py (1)
  • mpt_vendor (19-20)
tests/e2e/commerce/order/subscription/conftest.py (1)
  • order_subscription_factory (6-24)
tests/e2e/commerce/conftest.py (3)
  • order_id (16-17)
  • subscription_id (56-57)
  • invalid_subscription_id (66-67)
🪛 Ruff (0.14.8)
tests/e2e/commerce/order/subscription/test_async_subscription.py

22-22: Unused noqa directive (unknown: WPS421)

Remove unused noqa directive

(RUF100)


34-34: Unused function argument: created_order_subscription

(ARG001)


45-45: Unused function argument: created_order_subscription

(ARG001)

tests/e2e/commerce/order/subscription/conftest.py

11-11: Unused function argument: quantity

(ARG001)

tests/e2e/commerce/order/subscription/test_sync_subscription.py

22-22: Unused noqa directive (unknown: WPS421)

Remove unused noqa directive

(RUF100)


34-34: Unused function argument: created_order_subscription

(ARG001)


45-45: Unused function argument: created_order_subscription

(ARG001)

🔇 Additional comments (4)
e2e_config.test.json (1)

29-29: LGTM!

The new configuration key aligns with the agreement_subscription_line_id fixture and supports the order subscription test infrastructure.

tests/e2e/commerce/conftest.py (1)

55-96: LGTM!

The new fixtures follow the established patterns in this file. The subscription_factory correctly uses all its parameters including quantity.

tests/e2e/commerce/order/subscription/test_sync_subscription.py (1)

34-41: Unused created_order_subscription argument is intentional for test setup.

The created_order_subscription fixture is intentionally included to ensure a subscription exists before the test runs, even though the result isn't directly used. This is a valid pattern for fixtures with side effects. Consider adding a brief comment to clarify this intent.

tests/e2e/commerce/order/subscription/test_async_subscription.py (1)

71-74: Good use of synchronous test function with async fixture.

Correctly using def instead of async def since the test contains no await expressions. pytest-asyncio will resolve the async fixture automatically. Based on learnings.

@robcsegal robcsegal force-pushed the MPT-14909-add-e-2-e-tests-for-commerce-order-subscription branch from 642ea3a to 2d0ae2d Compare December 15, 2025 20:50
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
tests/e2e/commerce/conftest.py (1)

70-96: Code duplication with tests/e2e/commerce/subscription/conftest.py.

The subscription_factory fixture is duplicated between this file and tests/e2e/commerce/subscription/conftest.py (lines 15-40). Both factories have identical logic, parameters, and structure.

Consider consolidating these factories to eliminate duplication. Options:

  1. Keep only the factory in the more general location (tests/e2e/commerce/conftest.py) and remove the duplicate in the subscription-specific conftest
  2. Extract to a shared utility module if needed in multiple locations

Apply this pattern to maintain DRY:

# Keep in tests/e2e/commerce/conftest.py (this file)
@pytest.fixture
def subscription_factory(subscription_agreement_id, subscription_item_id):
    @freeze_time("2025-11-14T09:00:00.000Z")
    def factory(
        name: str = "E2E Created Subscription",
        external_vendor_id: str = "ext-vendor-id",
        quantity: int = 1,
    ):
        return {
            "name": name,
            "startDate": "2025-11-03T09:00:00.000Z",
            "commitmentDate": "2026-11-02T09:00:00.000Z",
            "autoRenew": True,
            "agreement": {"id": subscription_agreement_id},
            "externalIds": {"vendor": external_vendor_id},
            "template": None,
            "lines": [
                {
                    "item": {"id": subscription_item_id},
                    "quantity": quantity,
                    "price": {"unitPP": 10},
                }
            ],
            "parameters": {"fulfillment": []},
        }

    return factory

And remove the duplicate from tests/e2e/commerce/subscription/conftest.py.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 642ea3a and 2d0ae2d.

📒 Files selected for processing (5)
  • e2e_config.test.json (1 hunks)
  • tests/e2e/commerce/conftest.py (2 hunks)
  • tests/e2e/commerce/order/subscription/conftest.py (1 hunks)
  • tests/e2e/commerce/order/subscription/test_async_subscription.py (1 hunks)
  • tests/e2e/commerce/order/subscription/test_sync_subscription.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/e2e/commerce/order/subscription/conftest.py
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-12-12T15:02:20.732Z
Learnt from: robcsegal
Repo: softwareone-platform/mpt-api-python-client PR: 160
File: tests/e2e/commerce/agreement/attachment/test_async_agreement_attachment.py:55-58
Timestamp: 2025-12-12T15:02:20.732Z
Learning: In pytest with pytest-asyncio, if a test function uses async fixtures but contains no await, declare the test function as def (synchronous) instead of async def. Pytest-asyncio will resolve the async fixtures automatically; this avoids linter complaints about unnecessary async functions. This pattern applies to any test file under the tests/ directory that uses such fixtures.

Applied to files:

  • tests/e2e/commerce/conftest.py
  • tests/e2e/commerce/order/subscription/test_sync_subscription.py
  • tests/e2e/commerce/order/subscription/test_async_subscription.py
🧬 Code graph analysis (2)
tests/e2e/commerce/conftest.py (5)
tests/e2e/commerce/subscription/conftest.py (1)
  • factory (18-39)
tests/e2e/conftest.py (1)
  • e2e_config (89-92)
tests/e2e/commerce/order/subscription/conftest.py (1)
  • factory (8-21)
tests/e2e/commerce/asset/conftest.py (1)
  • factory (16-35)
tests/e2e/commerce/agreement/conftest.py (1)
  • factory (20-49)
tests/e2e/commerce/order/subscription/test_async_subscription.py (6)
mpt_api_client/exceptions.py (1)
  • MPTAPIError (20-42)
mpt_api_client/rql/query_builder.py (1)
  • RQLQuery (115-524)
tests/e2e/conftest.py (1)
  • async_mpt_vendor (24-27)
tests/e2e/commerce/order/subscription/conftest.py (1)
  • order_subscription_factory (6-23)
tests/e2e/commerce/conftest.py (3)
  • order_id (16-17)
  • subscription_id (56-57)
  • invalid_subscription_id (66-67)
mpt_api_client/models/model.py (1)
  • id (119-121)
🪛 Ruff (0.14.8)
tests/e2e/commerce/order/subscription/test_sync_subscription.py

22-22: Unused noqa directive (unknown: WPS421)

Remove unused noqa directive

(RUF100)


34-34: Unused function argument: created_order_subscription

(ARG001)


45-45: Unused function argument: created_order_subscription

(ARG001)

tests/e2e/commerce/order/subscription/test_async_subscription.py

22-22: Unused noqa directive (unknown: WPS421)

Remove unused noqa directive

(RUF100)


34-34: Unused function argument: created_order_subscription

(ARG001)


45-45: Unused function argument: created_order_subscription

(ARG001)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (18)
e2e_config.test.json (1)

29-29: LGTM!

The new configuration key is properly integrated with the new order subscription test fixtures and follows the existing naming convention.

tests/e2e/commerce/conftest.py (3)

2-2: LGTM!

The freezegun import is correctly used in the subscription_factory fixture to ensure deterministic timestamps in test data.


55-62: LGTM!

The new fixtures properly retrieve configuration values and follow the established pattern for e2e config fixtures.


65-67: LGTM!

The invalid subscription ID fixture provides a well-formed but non-existent ID for negative test cases.

tests/e2e/commerce/order/subscription/test_async_subscription.py (7)

1-6: LGTM!

The imports and test markers are appropriate for async e2e tests. The flaky marker is a good practice for tests that interact with external APIs.


25-32: LGTM!

The test correctly validates retrieval of an order subscription by ID.


34-42: LGTM!

The test correctly validates listing order subscriptions. The created_order_subscription fixture parameter is necessary to ensure at least one subscription exists before listing—this is a standard e2e test pattern. The static analysis warning about the unused parameter is a false positive.


44-51: LGTM!

The test correctly validates the 404 error handling for non-existent subscriptions. While the created_order_subscription fixture parameter appears unused, it may be included for consistency or to ensure the API is in a valid state before testing the negative case.


54-66: LGTM!

The test correctly validates filtering order subscriptions using RQLQuery with multiple filters and field selection. The past review comment about removing an unused subscription_id fixture parameter appears to have already been addressed.


69-85: LGTM!

Both tests are correctly implemented:

  • test_create_order_subscription appropriately uses a synchronous function signature since it only verifies the fixture result (per project learnings)
  • test_update_order_subscription correctly uses async/await for the API update call

88-93: LGTM!

The test correctly validates the delete operation. No assertion is needed since the operation either succeeds or raises an exception.

tests/e2e/commerce/order/subscription/test_sync_subscription.py (7)

1-6: LGTM!

The imports and test markers are appropriate for synchronous e2e tests.


25-32: LGTM!

The test correctly validates retrieval of an order subscription by ID.


34-42: LGTM!

The test correctly validates listing order subscriptions. The created_order_subscription fixture parameter is necessary to ensure at least one subscription exists before listing. The static analysis warning is a false positive.


44-51: LGTM!

The test correctly validates the 404 error handling for non-existent subscriptions. While the created_order_subscription fixture parameter appears unused, it may be included for consistency or to ensure the API is in a valid state.


54-66: LGTM!

The test correctly validates filtering order subscriptions using RQLQuery. The past review comment about removing an unused subscription_id fixture parameter appears to have already been addressed.


69-85: LGTM!

Both tests correctly validate creation and update operations for order subscriptions.


88-94: LGTM!

The test correctly validates the delete operation. No assertion is needed since the operation either succeeds or raises an exception.

@robcsegal robcsegal force-pushed the MPT-14909-add-e-2-e-tests-for-commerce-order-subscription branch 3 times, most recently from 17635e2 to 3119766 Compare December 15, 2025 21:28
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (2)
tests/e2e/commerce/order/subscription/test_sync_subscription.py (1)

22-22: Remove unused noqa directive.

The # noqa: WPS421 directive is for wemake-python-styleguide. If the project uses only Ruff for linting, this directive is unnecessary.

Apply this diff:

-        print(f"TEARDOWN - Unable to delete subscription: {getattr(error, 'title', str(error))}")  # noqa: WPS421
+        print(f"TEARDOWN - Unable to delete subscription: {getattr(error, 'title', str(error))}")
tests/e2e/commerce/order/subscription/test_async_subscription.py (1)

22-22: Remove unused noqa directive.

Same as the sync version - the # noqa: WPS421 directive is unnecessary if the project uses only Ruff for linting.

Apply this diff:

-        print(f"TEARDOWN - Unable to delete subscription: {getattr(error, 'title', str(error))}")  # noqa: WPS421
+        print(f"TEARDOWN - Unable to delete subscription: {getattr(error, 'title', str(error))}")
🧹 Nitpick comments (1)
tests/e2e/commerce/order/subscription/conftest.py (1)

7-21: Consider removing @freeze_time if dates are hardcoded.

The @freeze_time decorator freezes the current time for deterministic behavior, but the factory returns hardcoded date strings ("2025-11-03T09:00:00.000Z" and "2026-11-02T09:00:00.000Z") rather than computed dates. If these dates should remain static, the @freeze_time decorator is unnecessary and can be removed for clarity.

If the dates should be dynamically computed relative to "now" (e.g., datetime.now(), datetime.now() + timedelta(days=365)), then the decorator is appropriate, but the implementation should use datetime calls instead of hardcoded strings.

Apply this diff if dates should remain static:

-    @freeze_time("2025-11-14T09:00:00.000Z")
     def factory(
         name: str = "E2E Created Order Subscription",
         external_vendor_id: str = "ext-vendor-id",

Or update to use dynamic dates if that's the intent:

+from datetime import datetime, timedelta
+
 @pytest.fixture
 def order_subscription_factory(agreement_subscription_line_id):
     @freeze_time("2025-11-14T09:00:00.000Z")
     def factory(
         name: str = "E2E Created Order Subscription",
         external_vendor_id: str = "ext-vendor-id",
     ):
+        start_date = datetime.now().isoformat() + "Z"
+        commitment_date = (datetime.now() + timedelta(days=365)).isoformat() + "Z"
         return {
             "name": name,
-            "startDate": "2025-11-03T09:00:00.000Z",
-            "commitmentDate": "2026-11-02T09:00:00.000Z",
+            "startDate": start_date,
+            "commitmentDate": commitment_date,
             "autoRenew": True,
             "externalIds": {"vendor": external_vendor_id},
             "template": None,
             "lines": [{"id": agreement_subscription_line_id}],
             "parameters": {"fulfillment": []},
         }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 17635e2 and 3119766.

📒 Files selected for processing (5)
  • e2e_config.test.json (1 hunks)
  • tests/e2e/commerce/conftest.py (1 hunks)
  • tests/e2e/commerce/order/subscription/conftest.py (1 hunks)
  • tests/e2e/commerce/order/subscription/test_async_subscription.py (1 hunks)
  • tests/e2e/commerce/order/subscription/test_sync_subscription.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/e2e/commerce/conftest.py
  • e2e_config.test.json
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-12-12T15:02:20.732Z
Learnt from: robcsegal
Repo: softwareone-platform/mpt-api-python-client PR: 160
File: tests/e2e/commerce/agreement/attachment/test_async_agreement_attachment.py:55-58
Timestamp: 2025-12-12T15:02:20.732Z
Learning: In pytest with pytest-asyncio, if a test function uses async fixtures but contains no await, declare the test function as def (synchronous) instead of async def. Pytest-asyncio will resolve the async fixtures automatically; this avoids linter complaints about unnecessary async functions. This pattern applies to any test file under the tests/ directory that uses such fixtures.

Applied to files:

  • tests/e2e/commerce/order/subscription/test_async_subscription.py
  • tests/e2e/commerce/order/subscription/test_sync_subscription.py
  • tests/e2e/commerce/order/subscription/conftest.py
📚 Learning: 2025-11-27T00:05:54.701Z
Learnt from: robcsegal
Repo: softwareone-platform/mpt-api-python-client PR: 131
File: tests/e2e/accounts/accounts_users/test_async_accounts_users.py:0-0
Timestamp: 2025-11-27T00:05:54.701Z
Learning: In pytest-asyncio, async fixtures are automatically resolved before being passed to test functions (both sync and async). Test functions receive the yielded value from async fixtures, not coroutines, so fixture parameters should never be awaited. A sync test function can use async fixtures without any special handling.

Applied to files:

  • tests/e2e/commerce/order/subscription/test_async_subscription.py
🧬 Code graph analysis (3)
tests/e2e/commerce/order/subscription/test_async_subscription.py (5)
mpt_api_client/exceptions.py (1)
  • MPTAPIError (20-42)
mpt_api_client/rql/query_builder.py (1)
  • RQLQuery (115-524)
tests/e2e/conftest.py (1)
  • async_mpt_vendor (24-27)
tests/e2e/commerce/order/subscription/conftest.py (1)
  • order_subscription_factory (6-23)
mpt_api_client/models/model.py (1)
  • id (119-121)
tests/e2e/commerce/order/subscription/test_sync_subscription.py (5)
mpt_api_client/exceptions.py (1)
  • MPTAPIError (20-42)
mpt_api_client/rql/query_builder.py (1)
  • RQLQuery (115-524)
tests/e2e/commerce/order/subscription/test_async_subscription.py (8)
  • created_order_subscription (10-22)
  • test_get_order_subscription_by_id (25-31)
  • test_list_order_subscriptions (34-41)
  • test_get_order_subscription_by_id_not_found (44-51)
  • test_filter_order_subscriptions (54-66)
  • test_create_order_subscription (69-72)
  • test_update_order_subscription (75-85)
  • test_delete_order_subscription (88-93)
tests/e2e/conftest.py (1)
  • mpt_vendor (19-20)
tests/e2e/commerce/order/subscription/conftest.py (1)
  • order_subscription_factory (6-23)
tests/e2e/commerce/order/subscription/conftest.py (1)
tests/e2e/commerce/conftest.py (1)
  • agreement_subscription_line_id (60-61)
🪛 Ruff (0.14.8)
tests/e2e/commerce/order/subscription/test_async_subscription.py

22-22: Unused noqa directive (unknown: WPS421)

Remove unused noqa directive

(RUF100)


34-34: Unused function argument: created_order_subscription

(ARG001)


45-45: Unused function argument: created_order_subscription

(ARG001)

tests/e2e/commerce/order/subscription/test_sync_subscription.py

22-22: Unused noqa directive (unknown: WPS421)

Remove unused noqa directive

(RUF100)


34-34: Unused function argument: created_order_subscription

(ARG001)


45-45: Unused function argument: created_order_subscription

(ARG001)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (1)
tests/e2e/commerce/order/subscription/test_async_subscription.py (1)

69-72: Correct use of synchronous test with async fixture.

The test correctly uses def instead of async def since there's no await in the function body. Pytest-asyncio automatically resolves the async fixture created_order_subscription before passing it to the test. This follows the project's established pattern.

Based on learnings, this pattern avoids unnecessary async functions when no await is needed.

@robcsegal robcsegal force-pushed the MPT-14909-add-e-2-e-tests-for-commerce-order-subscription branch from 3119766 to a47325a Compare December 16, 2025 13:57
@sonarqubecloud
Copy link

@robcsegal robcsegal merged commit 9521013 into main Dec 16, 2025
6 checks passed
@robcsegal robcsegal deleted the MPT-14909-add-e-2-e-tests-for-commerce-order-subscription branch December 16, 2025 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants