Skip to content

Conversation

@albertsola
Copy link
Contributor

@albertsola albertsola commented Nov 28, 2025

Summary by CodeRabbit

  • Tests
    • Added comprehensive end-to-end tests (sync and async) for price list workflows: create, retrieve (by instance and id), iterate/filter, update, delete, and error cases (not-found, invalid data).
    • Added fixtures to manage temporary price list resources and expose the price-lists service for tests.
  • Tests — Helpers
    • Added reusable async/sync helpers for creating/tearing down resources, asserting filtered iterations, and verifying updates.

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

@coderabbitai
Copy link

coderabbitai bot commented Nov 28, 2025

Walkthrough

Adds end-to-end tests, fixtures, and helpers for catalog price lists: new sync and async test modules, conftest fixtures to create/manage price lists, and test helper functions for create/delete teardown, filtering/iterate assertions, and update assertions.

Changes

Cohort / File(s) Summary
Test helpers
tests/e2e/helper.py
New sync/async helpers: create_fixture_resource_and_delete / async_create_fixture_resource_and_delete (create, yield, teardown with MPTAPIError handling); filter/iterate assertion helpers (assert_service_filter_with_iterate, assert_async_service_filter_with_iterate); update assertion helpers (assert_update_resource, assert_async_update_resource).
Price list fixtures
tests/e2e/catalog/price_lists/conftest.py
New pytest fixtures: price_list_data(product_id) (payload generator), price_lists_service(mpt_ops) (service accessor), created_price_list(price_lists_service, price_list_data) (create-and-teardown fixture), and price_list_id(created_price_list) (extracts id).
Async price list tests
tests/e2e/catalog/price_lists/test_async_price_lists.py
New async test module using async fixtures (async_price_lists_service, async_created_price_list) covering create, get (by instance/id), filter+iterate, update, delete, not-found (404), and invalid-data (400) scenarios; uses helper assertions and flaky markers.
Sync price list tests
tests/e2e/catalog/price_lists/test_sync_price_lists.py
New sync test module covering create, get (by instance/id), iterate/filter, update, delete, not-found (404), and invalid-data (400); uses fixtures (created_price_list, product_id, price_lists_service, short_uuid) and helper assertions; tests marked flaky.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Areas to focus:
    • tests/e2e/helper.py — correct async/sync create-yield-delete flow and robust MPTAPIError handling during teardown.
    • tests/e2e/catalog/price_lists/conftest.py — fixture wiring, payload fields (currency, defaultMarkup, product ref), and cleanup semantics.
    • tests/e2e/catalog/price_lists/test_async_price_lists.py — async fixture usage and cleanup correctness.
    • Error-case assertions in both test modules (404 and 400 expectations) and flaky markers.

Poem

🐰 I hopped through fixtures, async and plain,
I seeded price lists, then cleaned them again.
With iterate and filter, updates in tow,
Tests twitched and passed in a soft-running flow.
Nose twitch, carrot cheer — code gardens grow.

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 'MPT-14896 E2E for catalog/price_lists' clearly and specifically describes the main change: adding end-to-end tests for the price lists functionality in the catalog module.
✨ 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 e2e/catalog/MPT-14896-price-lists-and-price-lists-items

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

@github-actions
Copy link

github-actions bot commented Nov 28, 2025

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

Generated by 🚫 dangerJS against e4cb857

@albertsola albertsola force-pushed the e2e/catalog/MPT-14896-price-lists-and-price-lists-items branch from f6a3967 to 74cd8ee Compare November 28, 2025 15:47
@albertsola albertsola marked this pull request as ready for review November 28, 2025 15:47
@@ -0,0 +1,68 @@
from contextlib import asynccontextmanager, contextmanager
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@svazquezco I believe you were suggesting something like these.

If these is what you mean with generic tests, let me know and I will refactor the rest of the tests to use this.

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: 1

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

13-72: Sync price list e2e coverage looks solid

The fixture-backed tests exercise create, multiple get paths, iteration, filtering, update, delete, and error cases (404/400) in a clear way; the patterns align nicely with the shared helpers.

One optional improvement: in test_delete_price_list, you could add a follow-up get expecting a 404 to assert deletion behavior explicitly, but current coverage is already useful.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9976f92 and 74cd8ee.

📒 Files selected for processing (4)
  • tests/e2e/catalog/price_lists/conftest.py (1 hunks)
  • tests/e2e/catalog/price_lists/test_async_price_lists.py (1 hunks)
  • tests/e2e/catalog/price_lists/test_sync_price_lists.py (1 hunks)
  • tests/e2e/helper.py (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-27T00:05:54.691Z
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.691Z
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/helper.py
🧬 Code graph analysis (2)
tests/e2e/catalog/price_lists/test_sync_price_lists.py (4)
tests/e2e/helper.py (3)
  • assert_service_filter_with_iterate (42-50)
  • assert_update_resource (53-59)
  • create_fixture_resource_and_delete (20-28)
mpt_api_client/exceptions.py (1)
  • MPTAPIError (20-42)
tests/e2e/catalog/price_lists/conftest.py (1)
  • price_list_data (5-12)
tests/e2e/conftest.py (2)
  • product_id (96-97)
  • short_uuid (101-102)
tests/e2e/helper.py (3)
mpt_api_client/rql/query_builder.py (1)
  • RQLQuery (115-524)
mpt_api_client/exceptions.py (1)
  • MPTAPIError (20-42)
mpt_api_client/models/model.py (1)
  • id (119-121)
🪛 GitHub Actions: PR build and merge
tests/e2e/catalog/price_lists/test_sync_price_lists.py

[error] 2-2: ImportError during test collection: No module named 'e2e'

tests/e2e/catalog/price_lists/test_async_price_lists.py

[error] 2-2: ImportError during test collection: No module named 'e2e'

🪛 Ruff (0.14.6)
tests/e2e/helper.py

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

Remove unused noqa directive

(RUF100)


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

Remove unused noqa directive

(RUF100)

🔇 Additional comments (8)
tests/e2e/helper.py (4)

7-17: Async create/delete helper looks correct

Resource lifecycle is handled cleanly: create once, yield to the test, and always attempt delete in teardown while swallowing API errors so tests don’t fail on cleanup.


19-28: Sync create/delete helper mirrors async version appropriately

Sync helper mirrors the async behavior and keeps teardown concerns localized; good reuse for multiple tests.


31-40: Filter+iterate assertion helpers are sound

Using RQLQuery(id=filter_by_id) and asserting a single result with matching id gives a concise, reusable check for filter behavior in both async and sync paths.

Also applies to: 42-51


53-60: Update assertion helpers provide useful coverage

Update helpers correctly verify id stability and that the updated field reflects in to_dict(), which is exactly what the e2e tests need.

Also applies to: 62-68

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

4-22: Price list fixtures are well-structured

Payload, service, and id fixtures are clean and reusable, and they match how the sync/async tests use them.

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

13-74: Async price list tests use fixtures and helpers correctly

Async fixtures, the async contextmanager for resource lifecycle, and the helper coroutines for filter/update are wired correctly, and the tests cover the same CRUD and error scenarios as the sync suite.

test_create_price_list being a sync function that consumes an async fixture’s value without await is fine under pytest-asyncio, which resolves async fixtures before injection. Based on learnings, this is the intended pattern.


2-6: Import pattern is correct and follows established codebase convention—no changes needed.

The from e2e.helper import pattern is the correct import style for this codebase and is already used consistently in both test_async_price_lists.py and test_sync_price_lists.py.

The repository's pyproject.toml explicitly configures pythonpath = "." with testpaths = "tests", which makes the e2e import path valid. Both tests/__init__.py and tests/e2e/__init__.py exist as package markers. When pytest runs from the repository root, e2e.helper correctly resolves to tests/e2e/helper.py. The GitHub CI workflows (cron-main-e2e.yml, pr-build-merge.yml) run tests successfully with this import pattern, and no CI failures related to this import are evident.

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

2-6: I need to verify the import path issue mentioned in the review comment. Let me investigate the actual module structure and how other tests import from the helper module.
<function_calls>


#!/bin/bash

1. Find helper.py location

echo "=== Locating helper.py ==="
find . -name "helper.py" -type f | head -20

2. Check if tests is a package

echo ""
echo "=== Checking for init.py files ==="
find tests -name "init.py" -type f 2>/dev/null | head -20

3. List structure of tests/e2e

echo ""
echo "=== Structure of tests/e2e directory ==="
ls -la tests/e2e/ 2>/dev/null || echo "Directory not found"


</function_calls>

<function_calls>


#!/bin/bash

Check how other e2e tests import from helper

echo "=== Checking imports of helper in e2e tests ==="
rg -n "from.*helper import" tests/e2e/ -A 2 -B 2

echo ""
echo "=== Alternative: checking all imports in e2e test files ==="
rg -n "^from|^import" tests/e2e/catalog/price_lists/ | head -20


</function_calls>

<function_calls>


#!/bin/bash

Check pytest configuration

echo "=== Checking pytest configuration files ==="
ls -la | grep -E "(pytest|setup|pyproject|conftest)"

echo ""
echo "=== Contents of pyproject.toml or pytest.ini ==="
cat pyproject.toml 2>/dev/null | grep -A 10 "[tool.pytest" || echo "No pytest config in pyproject.toml"
cat pytest.ini 2>/dev/null || echo "No pytest.ini found"
cat setup.cfg 2>/dev/null | grep -A 10 "[tool:pytest" || echo "No pytest config in setup.cfg"

echo ""
echo "=== Checking conftest.py files ==="
find . -name "conftest.py" | head -10


</function_calls>

<function_calls>


#!/bin/bash

Check the actual test file and surrounding files

echo "=== Contents of test file directory ==="
ls -la tests/e2e/catalog/price_lists/ 2>/dev/null | head -20

echo ""
echo "=== First 20 lines of the test file to see imports ==="
head -20 tests/e2e/catalog/price_lists/test_sync_price_lists.py 2>/dev/null || echo "File not found"


</function_calls>

<function_calls>


#!/bin/bash

Search for ALL imports of helper to understand the pattern

echo "=== All imports referencing 'helper' in tests directory ==="
rg -n "helper" tests/e2e --type py | grep -E "(^from|^import)" | head -30


</function_calls>

Comment on lines +13 to +16
try:
await service.delete(resource.id)
except MPTAPIError as error:
print(f"TEARDOWN - Unable to delete resource {resource}: {error.title}") # noqa: WPS421
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Remove unused/unknown noqa codes on teardown prints

Ruff reports RUF100 because WPS421 isn’t a known rule here, so these # noqa: WPS421 comments are now lint errors. Since print isn’t otherwise flagged, you can safely drop the noqa markers.

Suggested change:

-    except MPTAPIError as error:
-        print(f"TEARDOWN - Unable to delete resource {resource}: {error.title}")  # noqa:  WPS421
+    except MPTAPIError as error:
+        print(f"TEARDOWN - Unable to delete resource {resource}: {error.title}")
@@
-    except MPTAPIError as error:
-        print(f"TEARDOWN - Unable to delete resource {resource}: {error.title}")  # noqa:  WPS421
+    except MPTAPIError as error:
+        print(f"TEARDOWN - Unable to delete resource {resource}: {error.title}")

Also applies to: 25-28

🧰 Tools
🪛 Ruff (0.14.6)

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

Remove unused noqa directive

(RUF100)

🤖 Prompt for AI Agents
In tests/e2e/helper.py around lines 13-16 (and similarly lines 25-28), remove
the invalid/unknown inline noqa markers on the teardown print statements: the
prints are fine and the `# noqa:  WPS421` causes RUF100 because WPS421 is not
recognized; simply delete the `# noqa:  WPS421` suffixes so the print calls
remain and no lint suppression is present.

@albertsola albertsola force-pushed the e2e/catalog/MPT-14896-price-lists-and-price-lists-items branch from 74cd8ee to b75c04e Compare December 2, 2025 09:27
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: 1

♻️ Duplicate comments (2)
tests/e2e/helper.py (2)

13-16: Remove unused noqa directive.

The # noqa: WPS421 comment is flagged by Ruff as unknown, causing a lint error. Per the repository's learnings, while WPS rules are valid for wemake-python-styleguide, Ruff doesn't recognize them. Remove the noqa directive since the print statement is acceptable in teardown code.

Apply this diff:

     except MPTAPIError as error:
-        print(f"TEARDOWN - Unable to delete resource {resource}: {error.title}")  # noqa:  WPS421
+        print(f"TEARDOWN - Unable to delete resource {resource}: {error.title}")

25-28: Remove unused noqa directive.

Same as line 16, the # noqa: WPS421 comment should be removed.

Apply this diff:

     except MPTAPIError as error:
-        print(f"TEARDOWN - Unable to delete resource {resource}: {error.title}")  # noqa:  WPS421
+        print(f"TEARDOWN - Unable to delete resource {resource}: {error.title}")
🧹 Nitpick comments (2)
tests/e2e/catalog/price_lists/test_async_price_lists.py (2)

44-48: Consider removing unnecessary comment.

The # act comment on line 47 doesn't add meaningful information since the function call is self-explanatory. This is a common pattern in unit tests following Arrange-Act-Assert, but in this context the comment is redundant.

Apply this diff:

 async def test_filter_price_lists(async_price_lists_service, async_created_price_list):
     await assert_async_service_filter_with_iterate(
         async_price_lists_service, async_created_price_list.id, ["-product"]
-    )  # act
+    )

50-57: Consider removing unnecessary comment.

Similarly, the # act comment on line 56 is redundant.

Apply this diff:

 async def test_update_price_list(async_price_lists_service, async_created_price_list, short_uuid):
     await assert_async_update_resource(
         async_price_lists_service,
         async_created_price_list.id,
         "notes",
         f"Updated notes {short_uuid}",
-    )  # act
+    )
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 74cd8ee and b75c04e.

📒 Files selected for processing (4)
  • tests/e2e/catalog/price_lists/conftest.py (1 hunks)
  • tests/e2e/catalog/price_lists/test_async_price_lists.py (1 hunks)
  • tests/e2e/catalog/price_lists/test_sync_price_lists.py (1 hunks)
  • tests/e2e/helper.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/e2e/catalog/price_lists/conftest.py
  • tests/e2e/catalog/price_lists/test_sync_price_lists.py
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-12-01T10:48:52.572Z
Learnt from: jentyk
Repo: softwareone-platform/mpt-api-python-client PR: 136
File: tests/e2e/notifications/subscribers/conftest.py:14-25
Timestamp: 2025-12-01T10:48:52.572Z
Learning: The repository softwareone-platform/mpt-api-python-client uses wemake-python-styleguide linter, so noqa directives for WPS rules should not be flagged as unused.

Applied to files:

  • tests/e2e/helper.py
📚 Learning: 2025-11-27T00:05:54.691Z
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.691Z
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/helper.py
🪛 GitHub Actions: PR build and merge
tests/e2e/catalog/price_lists/test_async_price_lists.py

[error] 2-2: ModuleNotFoundError: No module named 'e2e'. Import during test collection failed. Command: 'pytest -v -p no:randomly --no-cov --junitxml=e2e-report.xml tests/e2e'.

🪛 Ruff (0.14.7)
tests/e2e/helper.py

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

Remove unused noqa directive

(RUF100)


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

Remove unused noqa directive

(RUF100)

Comment on lines 2 to 6
from e2e.helper import (
assert_async_service_filter_with_iterate,
assert_async_update_resource,
async_create_fixture_resource_and_delete,
)
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Fix import error blocking the build.

The import from e2e.helper import ... fails because the module path is incorrect. Since this file is located at tests/e2e/catalog/price_lists/test_async_price_lists.py and the helper is at tests/e2e/helper.py, use a relative import to navigate up the directory structure.

Apply this diff:

 import pytest
-from e2e.helper import (
+from ...helper import (
     assert_async_service_filter_with_iterate,
     assert_async_update_resource,
     async_create_fixture_resource_and_delete,
 )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
from e2e.helper import (
assert_async_service_filter_with_iterate,
assert_async_update_resource,
async_create_fixture_resource_and_delete,
)
from ...helper import (
assert_async_service_filter_with_iterate,
assert_async_update_resource,
async_create_fixture_resource_and_delete,
)
🧰 Tools
🪛 GitHub Actions: PR build and merge

[error] 2-2: ModuleNotFoundError: No module named 'e2e'. Import during test collection failed. Command: 'pytest -v -p no:randomly --no-cov --junitxml=e2e-report.xml tests/e2e'.

🤖 Prompt for AI Agents
In tests/e2e/catalog/price_lists/test_async_price_lists.py around lines 2-6, the
absolute import "from e2e.helper import ..." is incorrect for this package
layout; replace it with a package-relative import that climbs from
tests.e2e.catalog.price_lists up to tests.e2e and imports the same symbols, e.g.
change to "from ...helper import assert_async_service_filter_with_iterate,
assert_async_update_resource, async_create_fixture_resource_and_delete".

@albertsola albertsola force-pushed the e2e/catalog/MPT-14896-price-lists-and-price-lists-items branch from b75c04e to 00e1538 Compare December 2, 2025 09:35
@albertsola albertsola force-pushed the e2e/catalog/MPT-14896-price-lists-and-price-lists-items branch from 00e1538 to e4cb857 Compare December 2, 2025 09:37
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 (1)
tests/e2e/helper.py (1)

13-17: Remove unused noqa directives.

This issue was already flagged in a previous review. The # noqa: WPS421 markers on lines 16 and 28 are unknown to Ruff and should be removed.

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

24-28: Consider consolidating redundant get tests.

This test is very similar to test_get_price_list (lines 18-22). Both validate the get operation with essentially the same logic. Unless price_list_id and created_price_list fixtures represent meaningfully different test scenarios, you might consider consolidating these tests.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b75c04e and 00e1538.

📒 Files selected for processing (4)
  • tests/e2e/catalog/price_lists/conftest.py (1 hunks)
  • tests/e2e/catalog/price_lists/test_async_price_lists.py (1 hunks)
  • tests/e2e/catalog/price_lists/test_sync_price_lists.py (1 hunks)
  • tests/e2e/helper.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/e2e/catalog/price_lists/conftest.py
  • tests/e2e/catalog/price_lists/test_async_price_lists.py
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-12-01T10:48:52.572Z
Learnt from: jentyk
Repo: softwareone-platform/mpt-api-python-client PR: 136
File: tests/e2e/notifications/subscribers/conftest.py:14-25
Timestamp: 2025-12-01T10:48:52.572Z
Learning: The repository softwareone-platform/mpt-api-python-client uses wemake-python-styleguide linter, so noqa directives for WPS rules should not be flagged as unused.

Applied to files:

  • tests/e2e/helper.py
📚 Learning: 2025-11-27T00:05:54.691Z
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.691Z
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/helper.py
🧬 Code graph analysis (1)
tests/e2e/helper.py (2)
mpt_api_client/exceptions.py (1)
  • MPTAPIError (20-42)
mpt_api_client/models/model.py (1)
  • id (119-121)
🪛 Ruff (0.14.7)
tests/e2e/helper.py

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

Remove unused noqa directive

(RUF100)


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

Remove unused noqa directive

(RUF100)

⏰ 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 (12)
tests/e2e/helper.py (4)

31-40: LGTM!

The async filter and iterate assertion helper is well-structured and provides clear validation of filtering behavior with optional field selection.


42-51: LGTM!

The synchronous counterpart maintains consistency with the async version and correctly validates filtering behavior.


53-60: LGTM!

The update assertion helper correctly validates both the resource identity and the field update.


62-68: LGTM!

The async update assertion maintains consistency with the sync version and correctly validates update operations.

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

12-16: LGTM!

The creation test properly validates the product association.


18-22: LGTM!

The get operation is properly validated.


30-36: LGTM!

The iteration test correctly validates that the created resource can be found in the full result set.


44-48: LGTM!

The update test properly validates field modification using the helper function.


50-52: LGTM!

The delete test correctly validates successful deletion (no exception raised).


54-59: LGTM!

The not-found error test properly validates 404 handling.


61-65: LGTM!

The invalid data test properly validates 400 error handling for missing required fields.


38-42: No action needed. The select syntax ["-product"] is valid RQL syntax for field exclusion. This pattern is consistently used throughout the test suite and explicitly validated in unit tests (e.g., test_queryable_mixin_select), which confirm that minus-prefixed fields are correctly passed to the API query string as exclusions.

Likely an incorrect or invalid review comment.

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 (4)
tests/e2e/catalog/price_lists/test_async_price_lists.py (1)

63-74: Consider making negative assertions less dependent on full error messages

Both not-found and invalid-data tests match on the full "404 Not Found" / "400 One or more validation errors occurred" message, which can be brittle if wording changes. You might instead match only the status code in the regex (e.g. r"404") or capture the exception and assert on structured attributes like status / title to decouple from exact phrasing.

tests/e2e/helper.py (1)

7-28: Teardown helpers trade off strict cleanup for test robustness

The async and sync *_create_fixture_resource_and_delete helpers centralize resource lifecycle and avoid hard failures on teardown by catching MPTAPIError and logging. That’s reasonable for keeping e2e runs stable, but it also means failed deletes (including 5xx) won’t fail the test and can leave stray resources behind. If leaking resources becomes a problem, consider narrowing what you swallow (e.g., only ignore 404s) or re-raising on unexpected statuses while still logging.

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

12-52: Sync CRUD and iterate tests mirror async coverage effectively

The sync tests cover create/get/get-by-id/iterate/filter/update/delete using the same helpers as the async suite (assert_service_filter_with_iterate, assert_update_resource), which keeps behavior parity between sync and async clients. In test_iterate_price_lists, you could simplify to assert any(...) instead of storing result, but that’s purely stylistic.


54-65: Optional: Relax or restructure negative assertions for stability

As in the async module, the not-found and invalid-create tests assert on the full error message text via regex. To make these tests more resilient to wording changes, consider matching only the status code (e.g. r"404", r"400") or capturing the exception and asserting on structured fields like status / title instead of the exact combined string.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 00e1538 and e4cb857.

📒 Files selected for processing (4)
  • tests/e2e/catalog/price_lists/conftest.py (1 hunks)
  • tests/e2e/catalog/price_lists/test_async_price_lists.py (1 hunks)
  • tests/e2e/catalog/price_lists/test_sync_price_lists.py (1 hunks)
  • tests/e2e/helper.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/e2e/catalog/price_lists/conftest.py
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-11-27T00:05:54.691Z
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.691Z
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/helper.py
📚 Learning: 2025-12-01T10:48:52.572Z
Learnt from: jentyk
Repo: softwareone-platform/mpt-api-python-client PR: 136
File: tests/e2e/notifications/subscribers/conftest.py:14-25
Timestamp: 2025-12-01T10:48:52.572Z
Learning: The repository softwareone-platform/mpt-api-python-client uses wemake-python-styleguide linter, so noqa directives for WPS rules should not be flagged as unused.

Applied to files:

  • tests/e2e/helper.py
🧬 Code graph analysis (2)
tests/e2e/catalog/price_lists/test_sync_price_lists.py (5)
mpt_api_client/exceptions.py (1)
  • MPTAPIError (20-42)
tests/e2e/helper.py (2)
  • assert_service_filter_with_iterate (42-50)
  • assert_update_resource (53-59)
tests/e2e/catalog/price_lists/conftest.py (3)
  • created_price_list (23-25)
  • price_lists_service (18-19)
  • price_list_id (29-30)
tests/e2e/conftest.py (2)
  • product_id (96-97)
  • short_uuid (101-102)
tests/seed/catalog/test_product.py (1)
  • product (18-19)
tests/e2e/helper.py (3)
mpt_api_client/rql/query_builder.py (1)
  • RQLQuery (115-524)
mpt_api_client/exceptions.py (1)
  • MPTAPIError (20-42)
mpt_api_client/models/model.py (1)
  • id (119-121)
🪛 Ruff (0.14.7)
tests/e2e/helper.py

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

Remove unused noqa directive

(RUF100)


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

Remove unused noqa directive

(RUF100)

⏰ 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/catalog/price_lists/test_async_price_lists.py (3)

1-8: Import path and helper usage look correct

Using from tests.e2e.helper import ... aligns with the repo layout and resolves the previous ModuleNotFoundError while reusing the shared assertion helpers cleanly.


13-27: Async fixtures and context manager teardown pattern are appropriate

async_price_lists_service and async_created_price_list correctly wrap the async client and use async_create_fixture_resource_and_delete for lifecycle management; using an async fixture in a sync test (test_create_price_list) is valid and idiomatic with pytest-asyncio. Based on learnings, async fixtures should be consumed without explicit await in the test signature.


32-60: Async CRUD, filter, and update coverage is solid

The async tests for get/filter/update/delete exercise the service API end-to-end, and delegating filtering and update assertions to shared helpers (assert_async_service_filter_with_iterate, assert_async_update_resource) keeps the tests focused on behavior rather than mechanics.

tests/e2e/helper.py (2)

31-50: Filter helpers correctly assert a unique match by id

assert_async_service_filter_with_iterate and assert_service_filter_with_iterate build an RQLQuery(id=filter_by_id), optionally apply select, iterate, and assert exactly one result with the expected id. This nicely encapsulates the common pattern and keeps individual tests concise.


53-68: Update helpers provide clear assertions on updated fields

Both sync and async update helpers construct a minimal payload, call update, and then assert on the id and the updated field via to_dict(). This is a good, reusable pattern for validating partial updates in e2e tests.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 2, 2025

@albertsola albertsola merged commit 557ae6f into main Dec 2, 2025
6 checks passed
@albertsola albertsola deleted the e2e/catalog/MPT-14896-price-lists-and-price-lists-items branch December 2, 2025 09:49
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