Skip to content

Conversation

@albertsola
Copy link
Contributor

@albertsola albertsola commented Jan 7, 2026

Closes MPT-16791

  • Increase default HTTP timeouts from 10s to 20s for HTTPClient and AsyncHTTPClient (constructor defaults updated; unit tests adjusted).
  • Clear contents of prod.Dockerfile (file emptied/removed steps).
  • Refactor E2E catalog price lists tests to use ID-based fixtures (price_list_id, price_list_item_id); price list item resolution now uses RQLQuery filtering; async/sync tests and fixtures updated accordingly.
  • Add/adjust RQLQuery imports where needed for tests that filter by id.
  • Update tests/e2e/conftest.py: logo_fd now accepts project_root_path and builds the path from tests/data/logo.png.
  • CI: re-enable E2E step in .github/workflows/pull-request.yml (run E2E in PR workflow) using ReportPortal environment variables (RP_LAUNCH, RP_API_KEY, RP_ENDPOINT).

@github-actions
Copy link

github-actions bot commented Jan 7, 2026

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

Generated by 🚫 dangerJS against b9c631a

@albertsola albertsola force-pushed the fix/MPT-16791/Unreliable-e2e-pass-runs branch from 135fb99 to 6581aa2 Compare January 7, 2026 14:04
@coderabbitai
Copy link

coderabbitai bot commented Jan 7, 2026

📝 Walkthrough

Walkthrough

This PR increases default HTTP client timeouts from 10.0 → 20.0 (sync and async), removes contents of prod.Dockerfile, updates tests to use the new timeout and to consume ID-based fixtures (sourced from config), injects project root into a fixture, and re-enables the PR E2E workflow step.

Changes

Cohort / File(s) Summary
HTTP clients
mpt_api_client/http/async_client.py, mpt_api_client/http/client.py
Default timeout parameter in client __init__ changed from 10.020.0 (constructor signatures updated).
Unit tests (HTTP)
tests/unit/http/test_async_client.py, tests/unit/http/test_client.py
Tests updated to expect timeout=20.0 when asserting client initialization and env-based initialization.
Dockerfile removal
prod.Dockerfile
File contents removed (previous build, venv and CMD steps deleted).
CI workflow
.github/workflows/pull-request.yml
Re-enabled E2E step in PR workflow (un-commented/activated make e2e step using RP_* envs).
E2E fixture: project root injection
tests/e2e/conftest.py
logo_fd fixture now accepts project_root_path and builds path via project_root_path / "tests/data/logo.png".
E2E fixture: price_list id sourcing
tests/e2e/catalog/price_lists/conftest.py
price_list_id fixture now reads e2e_config["catalog.price_list.id"] instead of using created_price_list.id.
E2E fixtures & helpers: price list items
tests/e2e/catalog/price_lists/items/conftest.py, tests/e2e/catalog/price_lists/items/*
Added RQLQuery import; price_list_item fixture now accepts item_id and resolves via filter(RQLQuery(item__id=item_id)).iterate(); introduced price_list_item_id fixture; tests updated to use IDs and one invalid-data test renamed to reflect update behavior.
E2E tests (price lists — async & sync)
tests/e2e/catalog/price_lists/test_async_price_lists.py, tests/e2e/catalog/price_lists/test_sync_price_lists.py, tests/e2e/catalog/price_lists/items/test_async_price_list_items.py, tests/e2e/catalog/price_lists/items/test_sync_price_list_items.py
Tests changed to accept/use price_list_id / price_list_item_id fixtures (IDs used for get/filter/update); signatures and assertions adjusted accordingly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Jira Issue Key In Title ✅ Passed The PR title contains exactly one Jira issue key (MPT-16791) in the correct format.
Test Coverage Required ✅ Passed PR modifies 4 code files with timeout defaults and workflow changes, includes comprehensive test file updates.
Single Commit Required ✅ Passed The PR contains exactly one commit that consolidates test fixture modifications, timeout adjustments, and workflow updates into a single logical unit.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

@albertsola albertsola force-pushed the fix/MPT-16791/Unreliable-e2e-pass-runs branch from 6581aa2 to b9c631a Compare January 7, 2026 14:06
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

🧹 Nitpick comments (1)
tests/e2e/catalog/price_lists/items/conftest.py (1)

26-27: Consider handling empty results gracefully.

next() will raise StopIteration if no items match the filter, which may produce a confusing error. Consider providing a default or a clearer error message.

♻️ Optional: Add a descriptive error for missing items
 @pytest.fixture
 def price_list_item(price_list_items_service, item_id):
-    return next(price_list_items_service.filter(RQLQuery(item__id=item_id)).iterate())
+    try:
+        return next(price_list_items_service.filter(RQLQuery(item__id=item_id)).iterate())
+    except StopIteration:
+        raise ValueError(f"No price list item found for item_id={item_id}") from None
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 67fe877 and 6581aa2.

📒 Files selected for processing (11)
  • mpt_api_client/http/async_client.py
  • mpt_api_client/http/client.py
  • prod.Dockerfile
  • tests/e2e/catalog/price_lists/conftest.py
  • tests/e2e/catalog/price_lists/items/conftest.py
  • tests/e2e/catalog/price_lists/items/test_async_price_list_items.py
  • tests/e2e/catalog/price_lists/items/test_sync_price_list_items.py
  • tests/e2e/catalog/price_lists/test_async_price_lists.py
  • tests/e2e/conftest.py
  • tests/unit/http/test_async_client.py
  • tests/unit/http/test_client.py
💤 Files with no reviewable changes (1)
  • prod.Dockerfile
🧰 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/catalog/price_lists/items/test_async_price_list_items.py
  • tests/e2e/conftest.py
  • tests/unit/http/test_async_client.py
  • tests/e2e/catalog/price_lists/items/test_sync_price_list_items.py
  • tests/e2e/catalog/price_lists/conftest.py
  • tests/unit/http/test_client.py
  • tests/e2e/catalog/price_lists/items/conftest.py
  • tests/e2e/catalog/price_lists/test_async_price_lists.py
🧬 Code graph analysis (3)
tests/e2e/catalog/price_lists/items/test_async_price_list_items.py (2)
tests/e2e/catalog/price_lists/items/conftest.py (3)
  • async_price_list_items_service (12-13)
  • price_list_item_id (31-32)
  • price_list_item_data (17-22)
tests/e2e/helper.py (1)
  • assert_async_service_filter_with_iterate (31-39)
tests/e2e/catalog/price_lists/items/conftest.py (2)
mpt_api_client/rql/query_builder.py (1)
  • RQLQuery (115-524)
tests/e2e/catalog/conftest.py (1)
  • item_id (5-6)
tests/e2e/catalog/price_lists/test_async_price_lists.py (3)
tests/e2e/catalog/price_lists/conftest.py (1)
  • price_list_id (29-30)
tests/e2e/conftest.py (2)
  • price_list_id (152-153)
  • short_uuid (101-102)
tests/e2e/helper.py (2)
  • assert_async_service_filter_with_iterate (31-39)
  • assert_async_update_resource (62-68)
⏰ 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 (11)
tests/e2e/conftest.py (1)

111-113: LGTM!

Using project_root_path for file path resolution is more robust than relative path resolution, ensuring consistent behavior regardless of the working directory during test execution.

tests/unit/http/test_client.py (1)

25-25: LGTM!

Test expectations correctly updated to match the new default timeout of 20.0 seconds in HTTPClient.

Also applies to: 44-44

tests/unit/http/test_async_client.py (1)

35-35: LGTM!

Test expectations correctly updated to match the new default timeout of 20.0 seconds in AsyncHTTPClient.

Also applies to: 54-54

mpt_api_client/http/client.py (1)

43-43: Timeout increase looks reasonable for E2E reliability.

Doubling the default timeout from 10.0 to 20.0 seconds should help with flaky E2E tests on slower network conditions. This is a public API default change, so consider documenting it in release notes if this library follows semantic versioning.

mpt_api_client/http/async_client.py (1)

30-30: LGTM!

Consistent default timeout of 20.0 seconds across both sync and async HTTP clients.

tests/e2e/catalog/price_lists/items/conftest.py (1)

30-32: LGTM!

The new price_list_item_id fixture cleanly extracts the ID for tests that only need the identifier.

tests/e2e/catalog/price_lists/conftest.py (1)

29-30: Approved: Good refactor to use configuration-based IDs.

Using e2e_config for price_list_id decouples this fixture from needing to create a price list, improving test reliability and speed. The created_price_list fixture remains actively used by other tests (test_sync_price_lists.py and test_async_price_lists.py), so no dead code concerns.

tests/e2e/catalog/price_lists/items/test_async_price_list_items.py (2)

11-28: LGTM! Clean refactor to ID-based fixtures.

The refactor from object-based fixtures (price_list_item) to ID-based fixtures (price_list_item_id) is consistent and correct across all three test functions. This reduces fixture dependencies and should improve test reliability.


38-44: Good semantic improvement with the function rename.

The function was renamed from test_create_price_list_item_invalid_data to test_update_price_list_item_invalid_data, which better reflects that it's testing the update operation with invalid data. The refactor to use price_list_item_id is consistent with other changes.

tests/e2e/catalog/price_lists/test_async_price_lists.py (1)

32-50: LGTM! Smart selective refactor pattern.

The refactor appropriately moves get, filter, and update tests to use the config-based price_list_id, while intentionally keeping create and delete tests with async_created_price_list fixtures. This pattern makes sense: read/update operations can use pre-existing resources from config, while create/delete operations require fresh, ephemeral resources.

tests/e2e/catalog/price_lists/items/test_sync_price_list_items.py (1)

11-40: LGTM! Consistent with async test refactor.

The refactor mirrors the changes in the async test file, maintaining consistency across the test suite. All four test functions have been correctly updated to use price_list_item_id instead of the price_list_item object, and the function rename on line 36 appropriately clarifies the test's intent.

@albertsola albertsola force-pushed the fix/MPT-16791/Unreliable-e2e-pass-runs branch from b9c631a to 34bbe23 Compare January 7, 2026 17:46
@albertsola albertsola force-pushed the fix/MPT-16791/Unreliable-e2e-pass-runs branch from 34bbe23 to c92045c Compare January 8, 2026 07:59
@albertsola albertsola requested a review from a team as a code owner January 8, 2026 07:59
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

🤖 Fix all issues with AI agents
In @tests/e2e/catalog/price_lists/conftest.py:
- Around line 29-30: The async test_update_price_list is using the shared
price_list_id fixture causing mutation of a shared resource via
assert_async_update_resource() which calls service.update(); change the async
test to consume the async_created_price_list fixture instead of price_list_id so
it uses an isolated resource (mirror the sync test's created_price_list usage)
and ensure any assertions still reference the created fixture and its id when
calling assert_async_update_resource/service.update.

In @tests/e2e/catalog/price_lists/items/conftest.py:
- Around line 26-27: The helper price_list_item should handle the case where
next(...) raises StopIteration; wrap the call to
next(price_list_items_service.filter(RQLQuery(item__id=item_id)).iterate()) in a
try/except StopIteration and raise a clear error (e.g., RuntimeError or
AssertionError) that includes the missing item_id and that no price list item
was found, or alternatively return None and document the behavior; update
callers/tests accordingly so failures show the clearer message instead of an
unhandled StopIteration.

In @tests/e2e/catalog/price_lists/test_async_price_lists.py:
- Around line 44-50: test_update_price_list is mutating a shared config resource
(price_list_id) causing state leakage; change the test to use the isolated
disposable fixture async_created_price_list (same pattern as
test_delete_price_list) instead of price_list_id, update the test signature to
accept async_created_price_list (and/or rename local variable to price_list_id
from that fixture), and call assert_async_update_resource with
async_created_price_list so the test updates an ephemeral resource and preserves
isolation for concurrent runs.
📜 Review details

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 34bbe23 and c92045c.

📒 Files selected for processing (12)
  • .github/workflows/pull-request.yml
  • mpt_api_client/http/async_client.py
  • mpt_api_client/http/client.py
  • prod.Dockerfile
  • tests/e2e/catalog/price_lists/conftest.py
  • tests/e2e/catalog/price_lists/items/conftest.py
  • tests/e2e/catalog/price_lists/items/test_async_price_list_items.py
  • tests/e2e/catalog/price_lists/items/test_sync_price_list_items.py
  • tests/e2e/catalog/price_lists/test_async_price_lists.py
  • tests/e2e/conftest.py
  • tests/unit/http/test_async_client.py
  • tests/unit/http/test_client.py
💤 Files with no reviewable changes (1)
  • prod.Dockerfile
🚧 Files skipped from review as they are similar to previous changes (5)
  • mpt_api_client/http/client.py
  • mpt_api_client/http/async_client.py
  • tests/e2e/catalog/price_lists/items/test_sync_price_list_items.py
  • tests/e2e/conftest.py
  • tests/e2e/catalog/price_lists/items/test_async_price_list_items.py
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

⚙️ CodeRabbit configuration file

**/*.py: Do not suggest formatting changes or mention code formatting using Black. Instead use Ruff or Flake8

Files:

  • tests/e2e/catalog/price_lists/test_async_price_lists.py
  • tests/unit/http/test_client.py
  • tests/e2e/catalog/price_lists/conftest.py
  • tests/e2e/catalog/price_lists/items/conftest.py
  • tests/unit/http/test_async_client.py
**/*

⚙️ CodeRabbit configuration file

**/*: When reviewing subsequent commits, always check if previous review comments have been addressed and acknowledge resolved issues.

Files:

  • tests/e2e/catalog/price_lists/test_async_price_lists.py
  • tests/unit/http/test_client.py
  • tests/e2e/catalog/price_lists/conftest.py
  • tests/e2e/catalog/price_lists/items/conftest.py
  • tests/unit/http/test_async_client.py
🧠 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/catalog/price_lists/test_async_price_lists.py
  • tests/unit/http/test_client.py
  • tests/e2e/catalog/price_lists/conftest.py
  • tests/e2e/catalog/price_lists/items/conftest.py
  • tests/unit/http/test_async_client.py
🧬 Code graph analysis (3)
tests/e2e/catalog/price_lists/test_async_price_lists.py (5)
tests/e2e/catalog/price_lists/test_sync_price_lists.py (3)
  • test_get_price_list (18-21)
  • test_filter_price_lists (38-41)
  • test_update_price_list (44-47)
tests/e2e/catalog/price_lists/conftest.py (1)
  • price_list_id (29-30)
tests/e2e/conftest.py (2)
  • price_list_id (152-153)
  • short_uuid (101-102)
mpt_api_client/models/model.py (1)
  • id (119-121)
tests/e2e/helper.py (2)
  • assert_async_service_filter_with_iterate (31-39)
  • assert_async_update_resource (62-68)
tests/e2e/catalog/price_lists/conftest.py (1)
tests/e2e/conftest.py (2)
  • price_list_id (152-153)
  • e2e_config (89-92)
tests/e2e/catalog/price_lists/items/conftest.py (4)
mpt_api_client/rql/query_builder.py (1)
  • RQLQuery (115-524)
tests/unit/resources/catalog/test_price_list_items.py (1)
  • price_list_items_service (10-13)
tests/e2e/catalog/conftest.py (1)
  • item_id (5-6)
mpt_api_client/models/model.py (1)
  • id (119-121)
⏰ 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 (6)
tests/unit/http/test_client.py (1)

25-25: LGTM! Timeout expectations correctly updated.

The test assertions now correctly expect a timeout of 20.0 seconds, aligning with the updated default timeout in the HTTPClient implementation. Both explicit initialization and environment-based initialization tests are updated consistently.

Also applies to: 44-44

tests/unit/http/test_async_client.py (1)

35-35: LGTM! Async client timeout expectations correctly updated.

The test assertions now correctly expect a timeout of 20.0 seconds, aligning with the updated default timeout in the AsyncHTTPClient implementation. Both explicit initialization and environment-based initialization tests are updated consistently, matching the changes in the synchronous client tests.

Also applies to: 54-54

tests/e2e/catalog/price_lists/items/conftest.py (1)

30-32: LGTM!

The price_list_item_id fixture correctly extracts the ID from the price_list_item fixture for use in tests.

tests/e2e/catalog/price_lists/test_async_price_lists.py (2)

32-35: LGTM!

Using the config-based price_list_id for read-only operations is appropriate and ensures the test can run against a stable, pre-existing resource.


38-41: LGTM!

Using the config-based price_list_id for filtering operations is appropriate for read-only tests.

.github/workflows/pull-request.yml (1)

39-44: Verify that the required secrets are configured in the GitHub repository settings.

The E2E test step correctly references RP_ENDPOINT and RP_API_KEY secrets using proper GitHub Actions syntax. Ensure these secrets are configured in the repository settings for the workflow to execute successfully.

@albertsola albertsola force-pushed the fix/MPT-16791/Unreliable-e2e-pass-runs branch from c92045c to f84ebae Compare January 8, 2026 08:40
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/e2e/catalog/price_lists/test_sync_price_lists.py (1)

1-1: Address Ruff formatting issue.

The pipeline indicates this file needs reformatting with ruff format.

Run the following command to fix the formatting:

#!/bin/bash
# Format the file with ruff
ruff format tests/e2e/catalog/price_lists/test_sync_price_lists.py
🧹 Nitpick comments (2)
tests/e2e/catalog/price_lists/test_sync_price_lists.py (1)

18-27: Duplicate test detected.

Both test_get_price_list and test_get_price_list_by_id (lines 18-21 and 24-27) appear to perform identical operations with identical assertions. Consider removing one of these duplicate tests.

♻️ Proposed fix
-def test_get_price_list(price_lists_service, price_list_id):
-    result = price_lists_service.get(price_list_id)
-
-    assert result.id == price_list_id
-
-
 def test_get_price_list_by_id(price_lists_service, price_list_id):
     result = price_lists_service.get(price_list_id)
 
     assert result.id == price_list_id
.github/workflows/pull-request.yml (1)

39-44: Consider passing ReportPortal credentials via environment variables only.

Good addition of E2E tests to the PR workflow! The ReportPortal pytest plugin supports reading RP_ENDPOINT and RP_API_KEY directly from environment variables. Since you're already setting both as environment variables (lines 43-44), you can simplify line 40 to remove the redundant CLI arguments:

Suggested change
-      run: make e2e args="--reportportal --rp-launch=$RP_LAUNCH --rp-api-key=$RP_API_KEY --rp-endpoint=$RP_ENDPOINT"
+      run: make e2e args="--reportportal --rp-launch=$RP_LAUNCH"

This approach is cleaner and reduces the surface area for accidental secret exposure in logs.

Also, verify that the 45-minute workflow timeout (line 14) remains sufficient with E2E tests now enabled.

📜 Review details

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c92045c and f84ebae.

📒 Files selected for processing (13)
  • .github/workflows/pull-request.yml
  • mpt_api_client/http/async_client.py
  • mpt_api_client/http/client.py
  • prod.Dockerfile
  • tests/e2e/catalog/price_lists/conftest.py
  • tests/e2e/catalog/price_lists/items/conftest.py
  • tests/e2e/catalog/price_lists/items/test_async_price_list_items.py
  • tests/e2e/catalog/price_lists/items/test_sync_price_list_items.py
  • tests/e2e/catalog/price_lists/test_async_price_lists.py
  • tests/e2e/catalog/price_lists/test_sync_price_lists.py
  • tests/e2e/conftest.py
  • tests/unit/http/test_async_client.py
  • tests/unit/http/test_client.py
💤 Files with no reviewable changes (1)
  • prod.Dockerfile
🚧 Files skipped from review as they are similar to previous changes (4)
  • tests/e2e/catalog/price_lists/items/conftest.py
  • tests/unit/http/test_async_client.py
  • mpt_api_client/http/async_client.py
  • mpt_api_client/http/client.py
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

⚙️ CodeRabbit configuration file

**/*.py: Do not suggest formatting changes or mention code formatting using Black. Instead use Ruff or Flake8

Files:

  • tests/e2e/catalog/price_lists/items/test_async_price_list_items.py
  • tests/e2e/catalog/price_lists/test_async_price_lists.py
  • tests/e2e/catalog/price_lists/conftest.py
  • tests/e2e/conftest.py
  • tests/unit/http/test_client.py
  • tests/e2e/catalog/price_lists/test_sync_price_lists.py
  • tests/e2e/catalog/price_lists/items/test_sync_price_list_items.py
**/*

⚙️ CodeRabbit configuration file

**/*: When reviewing subsequent commits, always check if previous review comments have been addressed and acknowledge resolved issues.

Files:

  • tests/e2e/catalog/price_lists/items/test_async_price_list_items.py
  • tests/e2e/catalog/price_lists/test_async_price_lists.py
  • tests/e2e/catalog/price_lists/conftest.py
  • tests/e2e/conftest.py
  • tests/unit/http/test_client.py
  • tests/e2e/catalog/price_lists/test_sync_price_lists.py
  • tests/e2e/catalog/price_lists/items/test_sync_price_list_items.py
🧠 Learnings (6)
📓 Common learnings
Learnt from: albertsola
Repo: softwareone-platform/mpt-api-python-client PR: 183
File: tests/e2e/catalog/price_lists/conftest.py:29-30
Timestamp: 2026-01-08T08:34:05.465Z
Learning: In the mpt-api-python-client E2E tests, the team intentionally reuses existing API resources (via e2e_config) for read-only operations and safe mutations (e.g., updating the "notes" field) to improve test execution speed. Only destructive/dangerous tests use isolated fixtures (created_price_list or async_created_price_list) that are created and cleaned up per test.
📚 Learning: 2026-01-08T08:34:19.306Z
Learnt from: albertsola
Repo: softwareone-platform/mpt-api-python-client PR: 183
File: tests/e2e/catalog/price_lists/items/conftest.py:26-27
Timestamp: 2026-01-08T08:34:19.306Z
Learning: In tests/e2e/catalog/price_lists/items/conftest.py, the price_list_item fixture is seeded to always provide an item. Do not add StopIteration handling in this test fixture since absence of items is not expected; treat StopIteration as an upstream test setup failure rather than a recoverable condition.

Applied to files:

  • tests/e2e/catalog/price_lists/items/test_async_price_list_items.py
  • tests/e2e/catalog/price_lists/test_async_price_lists.py
  • tests/e2e/catalog/price_lists/conftest.py
  • tests/e2e/catalog/price_lists/test_sync_price_lists.py
  • tests/e2e/catalog/price_lists/items/test_sync_price_list_items.py
📚 Learning: 2026-01-08T08:34:05.465Z
Learnt from: albertsola
Repo: softwareone-platform/mpt-api-python-client PR: 183
File: tests/e2e/catalog/price_lists/conftest.py:29-30
Timestamp: 2026-01-08T08:34:05.465Z
Learning: In end-to-end tests (e.g., tests/e2e/...), reuse existing API resources for read-only operations and safe mutations to speed up test execution. Reserve isolated fixtures (e.g., created_price_list) for destructive tests that require per-test creation and cleanup. Ensure tests document when a fixture creates/destroys data and clearly indicate which operations are destructive, so tests stay fast and properly isolated.

Applied to files:

  • tests/e2e/catalog/price_lists/items/test_async_price_list_items.py
  • tests/e2e/catalog/price_lists/test_async_price_lists.py
  • tests/e2e/catalog/price_lists/conftest.py
  • tests/e2e/conftest.py
  • tests/e2e/catalog/price_lists/test_sync_price_lists.py
  • tests/e2e/catalog/price_lists/items/test_sync_price_list_items.py
📚 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/catalog/price_lists/items/test_async_price_list_items.py
  • tests/e2e/catalog/price_lists/test_async_price_lists.py
  • tests/e2e/catalog/price_lists/conftest.py
  • tests/e2e/conftest.py
  • tests/unit/http/test_client.py
  • tests/e2e/catalog/price_lists/test_sync_price_lists.py
  • tests/e2e/catalog/price_lists/items/test_sync_price_list_items.py
📚 Learning: 2025-11-27T00:05:36.356Z
Learnt from: robcsegal
Repo: softwareone-platform/mpt-api-python-client PR: 131
File: tests/e2e/conftest.py:0-0
Timestamp: 2025-11-27T00:05:36.356Z
Learning: When reviewing PRs that add fixtures to a parent conftest that may duplicate fixtures in child conftest files, do not suggest removing the duplicates from child conftest files that are outside the scope of the PR's changes.

Applied to files:

  • tests/e2e/catalog/price_lists/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/catalog/price_lists/conftest.py
🧬 Code graph analysis (3)
tests/e2e/catalog/price_lists/items/test_async_price_list_items.py (2)
tests/e2e/catalog/price_lists/items/conftest.py (2)
  • price_list_item_id (31-32)
  • price_list_item_data (17-22)
tests/e2e/helper.py (1)
  • assert_async_service_filter_with_iterate (31-39)
tests/e2e/catalog/price_lists/test_async_price_lists.py (4)
tests/e2e/catalog/price_lists/conftest.py (1)
  • price_list_id (29-30)
tests/e2e/conftest.py (1)
  • price_list_id (152-153)
mpt_api_client/models/model.py (1)
  • id (119-121)
tests/e2e/helper.py (2)
  • assert_async_service_filter_with_iterate (31-39)
  • assert_async_update_resource (62-68)
tests/e2e/catalog/price_lists/conftest.py (1)
tests/e2e/conftest.py (1)
  • e2e_config (89-92)
🪛 GitHub Actions: PR build and merge
tests/e2e/catalog/price_lists/test_sync_price_lists.py

[error] 1-1: Ruff format check failed. File would be reformatted by 'ruff format'.

🔇 Additional comments (8)
tests/unit/http/test_client.py (2)

13-27: LGTM! Test correctly reflects the new default timeout.

The test now expects the HTTPClient to initialize with a 20.0 second timeout, matching the updated default in the implementation.


30-46: LGTM! Test correctly reflects the new default timeout.

The test now expects the HTTPClient initialized from environment variables to use a 20.0 second timeout, consistent with the updated default and the other initialization test.

tests/e2e/conftest.py (1)

111-113: LGTM! Improved consistency through dependency injection.

The refactoring to use the project_root_path fixture improves testability and aligns with the pattern established by other fixtures like e2e_config. The path construction is correct and explicit about dependencies.

tests/e2e/catalog/price_lists/conftest.py (1)

29-30: LGTM! Fixture refactored to use centralized config.

This change aligns with the team's pattern of reusing existing API resources (via e2e_config) for read-only and safe mutation tests, improving test execution speed.

tests/e2e/catalog/price_lists/test_async_price_lists.py (1)

32-50: LGTM! Tests correctly refactored to use ID-based fixtures.

The refactoring appropriately uses price_list_id for read-only and safe mutation operations (get, filter, update), while test_delete_price_list correctly retains the async_created_price_list fixture for destructive operations. This aligns with the team's pattern for balancing test speed and proper isolation.

tests/e2e/catalog/price_lists/test_sync_price_lists.py (1)

30-47: LGTM! Tests correctly refactored to use ID-based fixtures.

The refactoring appropriately uses price_list_id for read-only and safe mutation operations, while test_delete_price_list correctly retains the created_price_list fixture for destructive operations.

tests/e2e/catalog/price_lists/items/test_async_price_list_items.py (1)

11-44: LGTM! Tests correctly refactored to use ID-based fixtures.

The refactoring appropriately:

  • Uses price_list_item_id for all operations
  • Renames the invalid data test from "create" to "update" which better reflects the operation being tested
  • Uses appropriate invalid data ({"unitPP": "NaN"}) for validation testing

The pattern is consistent with the broader E2E test refactoring in this PR.

tests/e2e/catalog/price_lists/items/test_sync_price_list_items.py (1)

11-40: LGTM! Tests correctly refactored to use ID-based fixtures.

The refactoring is consistent with the async version and appropriately:

  • Uses price_list_item_id for all operations
  • Renames the invalid data test to reflect the actual operation (update)
  • Uses appropriate invalid data for validation testing

@albertsola albertsola force-pushed the fix/MPT-16791/Unreliable-e2e-pass-runs branch from f84ebae to 17716e1 Compare January 8, 2026 08:48
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/e2e/catalog/price_lists/test_sync_price_lists.py (1)

18-27: Remove duplicate test.

test_get_price_list (lines 18-21) and test_get_price_list_by_id (lines 24-27) now contain identical logic after the migration to price_list_id. Consider removing one of these tests to eliminate duplication.

♻️ Proposed fix to remove duplicate test
-def test_get_price_list(price_lists_service, price_list_id):
-    result = price_lists_service.get(price_list_id)
-
-    assert result.id == price_list_id
-
-
 def test_get_price_list_by_id(price_lists_service, price_list_id):
     result = price_lists_service.get(price_list_id)
 
     assert result.id == price_list_id
🧹 Nitpick comments (1)
tests/e2e/conftest.py (1)

73-75: Consider applying the same pattern to pdf_fd for consistency.

The logo_fd fixture now uses project_root_path for path construction, but pdf_fd still uses the relative path approach. For consistency and maintainability, consider updating pdf_fd to follow the same pattern.

♻️ Suggested refactor
 @pytest.fixture
-def pdf_fd():
-    icon_path = pathlib.Path(__file__).parent / "empty.pdf"
+def pdf_fd(project_root_path):
+    icon_path = project_root_path / "tests/e2e/empty.pdf"
     return pathlib.Path.open(icon_path, "rb")
📜 Review details

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f84ebae and 17716e1.

📒 Files selected for processing (13)
  • .github/workflows/pull-request.yml
  • mpt_api_client/http/async_client.py
  • mpt_api_client/http/client.py
  • prod.Dockerfile
  • tests/e2e/catalog/price_lists/conftest.py
  • tests/e2e/catalog/price_lists/items/conftest.py
  • tests/e2e/catalog/price_lists/items/test_async_price_list_items.py
  • tests/e2e/catalog/price_lists/items/test_sync_price_list_items.py
  • tests/e2e/catalog/price_lists/test_async_price_lists.py
  • tests/e2e/catalog/price_lists/test_sync_price_lists.py
  • tests/e2e/conftest.py
  • tests/unit/http/test_async_client.py
  • tests/unit/http/test_client.py
💤 Files with no reviewable changes (1)
  • prod.Dockerfile
🚧 Files skipped from review as they are similar to previous changes (7)
  • .github/workflows/pull-request.yml
  • tests/e2e/catalog/price_lists/conftest.py
  • tests/unit/http/test_async_client.py
  • mpt_api_client/http/client.py
  • mpt_api_client/http/async_client.py
  • tests/unit/http/test_client.py
  • tests/e2e/catalog/price_lists/items/test_sync_price_list_items.py
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

⚙️ CodeRabbit configuration file

**/*.py: Do not suggest formatting changes or mention code formatting using Black. Instead use Ruff or Flake8

Files:

  • tests/e2e/catalog/price_lists/test_sync_price_lists.py
  • tests/e2e/catalog/price_lists/items/test_async_price_list_items.py
  • tests/e2e/catalog/price_lists/test_async_price_lists.py
  • tests/e2e/catalog/price_lists/items/conftest.py
  • tests/e2e/conftest.py
**/*

⚙️ CodeRabbit configuration file

**/*: When reviewing subsequent commits, always check if previous review comments have been addressed and acknowledge resolved issues.

Files:

  • tests/e2e/catalog/price_lists/test_sync_price_lists.py
  • tests/e2e/catalog/price_lists/items/test_async_price_list_items.py
  • tests/e2e/catalog/price_lists/test_async_price_lists.py
  • tests/e2e/catalog/price_lists/items/conftest.py
  • tests/e2e/conftest.py
🧠 Learnings (4)
📓 Common learnings
Learnt from: albertsola
Repo: softwareone-platform/mpt-api-python-client PR: 183
File: tests/e2e/catalog/price_lists/conftest.py:29-30
Timestamp: 2026-01-08T08:34:05.465Z
Learning: In the mpt-api-python-client E2E tests, the team intentionally reuses existing API resources (via e2e_config) for read-only operations and safe mutations (e.g., updating the "notes" field) to improve test execution speed. Only destructive/dangerous tests use isolated fixtures (created_price_list or async_created_price_list) that are created and cleaned up per test.
📚 Learning: 2026-01-08T08:34:05.465Z
Learnt from: albertsola
Repo: softwareone-platform/mpt-api-python-client PR: 183
File: tests/e2e/catalog/price_lists/conftest.py:29-30
Timestamp: 2026-01-08T08:34:05.465Z
Learning: In end-to-end tests (e.g., tests/e2e/...), reuse existing API resources for read-only operations and safe mutations to speed up test execution. Reserve isolated fixtures (e.g., created_price_list) for destructive tests that require per-test creation and cleanup. Ensure tests document when a fixture creates/destroys data and clearly indicate which operations are destructive, so tests stay fast and properly isolated.

Applied to files:

  • tests/e2e/catalog/price_lists/test_sync_price_lists.py
  • tests/e2e/catalog/price_lists/items/test_async_price_list_items.py
  • tests/e2e/catalog/price_lists/test_async_price_lists.py
  • tests/e2e/catalog/price_lists/items/conftest.py
  • tests/e2e/conftest.py
📚 Learning: 2026-01-08T08:34:19.306Z
Learnt from: albertsola
Repo: softwareone-platform/mpt-api-python-client PR: 183
File: tests/e2e/catalog/price_lists/items/conftest.py:26-27
Timestamp: 2026-01-08T08:34:19.306Z
Learning: In tests/e2e/catalog/price_lists/items/conftest.py, the price_list_item fixture is seeded to always provide an item. Do not add StopIteration handling in this test fixture since absence of items is not expected; treat StopIteration as an upstream test setup failure rather than a recoverable condition.

Applied to files:

  • tests/e2e/catalog/price_lists/test_sync_price_lists.py
  • tests/e2e/catalog/price_lists/items/test_async_price_list_items.py
  • tests/e2e/catalog/price_lists/test_async_price_lists.py
  • tests/e2e/catalog/price_lists/items/conftest.py
📚 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/catalog/price_lists/test_sync_price_lists.py
  • tests/e2e/catalog/price_lists/items/test_async_price_list_items.py
  • tests/e2e/catalog/price_lists/test_async_price_lists.py
  • tests/e2e/catalog/price_lists/items/conftest.py
  • tests/e2e/conftest.py
🧬 Code graph analysis (3)
tests/e2e/catalog/price_lists/test_sync_price_lists.py (3)
tests/e2e/catalog/price_lists/conftest.py (2)
  • price_lists_service (18-19)
  • price_list_id (29-30)
tests/e2e/conftest.py (2)
  • price_list_id (152-153)
  • short_uuid (101-102)
tests/e2e/helper.py (2)
  • assert_service_filter_with_iterate (42-50)
  • assert_update_resource (53-59)
tests/e2e/catalog/price_lists/items/test_async_price_list_items.py (4)
tests/e2e/catalog/price_lists/items/conftest.py (3)
  • async_price_list_items_service (12-13)
  • price_list_item_id (31-32)
  • price_list_item_data (17-22)
tests/unit/resources/catalog/test_price_list_items.py (1)
  • async_price_list_items_service (17-20)
tests/e2e/helper.py (1)
  • assert_async_service_filter_with_iterate (31-39)
mpt_api_client/exceptions.py (1)
  • MPTAPIError (20-42)
tests/e2e/catalog/price_lists/test_async_price_lists.py (5)
tests/e2e/catalog/price_lists/test_sync_price_lists.py (3)
  • test_get_price_list (18-21)
  • test_filter_price_lists (38-39)
  • test_update_price_list (42-45)
tests/e2e/catalog/price_lists/conftest.py (1)
  • price_list_id (29-30)
tests/e2e/conftest.py (2)
  • price_list_id (152-153)
  • short_uuid (101-102)
mpt_api_client/models/model.py (1)
  • id (119-121)
tests/e2e/helper.py (2)
  • assert_async_service_filter_with_iterate (31-39)
  • assert_async_update_resource (62-68)
⏰ 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 (7)
tests/e2e/conftest.py (1)

111-112: LGTM! Improved consistency with project_root_path injection.

The change to inject project_root_path and use it for path construction improves consistency with other fixtures like e2e_config and makes the file path more explicit and maintainable.

tests/e2e/catalog/price_lists/items/test_async_price_list_items.py (1)

11-44: LGTM! Clean migration to ID-based fixtures.

The migration from price_list_item object to price_list_item_id is consistent across all test functions. The changes align with the PR's objective to improve test reliability by using config-based IDs.

tests/e2e/catalog/price_lists/items/conftest.py (3)

3-3: LGTM! Appropriate import added.

The RQLQuery import is necessary for the updated filtering logic in the price_list_item fixture.


30-32: LGTM! ID extraction fixture is straightforward.

The price_list_item_id fixture correctly extracts the ID from the resolved price_list_item.


26-27: No action required—the item_id fixture is properly defined.

The item_id fixture is already defined in tests/e2e/catalog/conftest.py and retrieves its value from the e2e configuration, making it available to all child test directories including tests/e2e/catalog/price_lists/items/. The fixture dependency is satisfied.

tests/e2e/catalog/price_lists/test_sync_price_lists.py (1)

30-45: LGTM! Tests correctly migrated to use price_list_id.

The iterate, filter, and update tests have been properly updated to use the price_list_id fixture instead of the created_price_list object. The changes are consistent with the PR's migration strategy.

tests/e2e/catalog/price_lists/test_async_price_lists.py (1)

32-50: LGTM! Async tests correctly migrated to ID-based fixtures.

The async price list tests have been properly updated to use price_list_id from the config instead of async_created_price_list. This change:

  • Improves test reliability by reusing existing resources
  • Maintains consistency with the sync test variant
  • Correctly preserves async function signatures

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 8, 2026

@albertsola
Copy link
Contributor Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jan 8, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@albertsola
Copy link
Contributor Author

@coderabbitai resolve

@coderabbitai
Copy link

coderabbitai bot commented Jan 8, 2026

✅ Actions performed

Comments resolved and changes approved.

@albertsola albertsola merged commit 46a898d into main Jan 8, 2026
4 checks passed
@albertsola albertsola deleted the fix/MPT-16791/Unreliable-e2e-pass-runs branch January 8, 2026 09:35
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.

5 participants