Skip to content

Conversation

@albertsola
Copy link
Contributor

@albertsola albertsola commented Dec 4, 2025

Summary by CodeRabbit

  • Tests
    • Added comprehensive end-to-end tests for authorization workflows (create, retrieve, filter, update, error handling), including asynchronous variants.
    • Reorganized and expanded test fixtures to centralize account-id handling and support new authorization tests.
    • Removed and renamed some existing fixtures as part of the reorganization, which may require updating dependent tests.

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

@coderabbitai
Copy link

coderabbitai bot commented Dec 4, 2025

Walkthrough

Centralized a new buyer_account_id fixture in tests/e2e/conftest.py, removed local buyer-related fixtures from module conftests, and added synchronous and asynchronous end-to-end tests plus supporting fixtures for catalog authorizations (create, get, filter, update, not-found behavior).

Changes

Cohort / File(s) Change Summary
Root fixture added
tests/e2e/conftest.py
Added buyer_account_id fixture returning e2e_config["accounts.buyer.account.id"].
Removed local buyer fixtures
tests/e2e/accounts/buyers/conftest.py, tests/e2e/catalog/pricing_policies/conftest.py
Removed buyer_account_id / buyer_id local fixtures; updated pricing_policy_data signature to accept buyer_account_id instead of buyer_id.
Authorization fixtures
tests/e2e/catalog/authorizations/conftest.py
Added authorizations_service fixture (wraps mpt_ops.catalog.authorizations) and authorization_data fixture that builds authorization payloads.
Authorization tests (sync & async)
tests/e2e/catalog/authorizations/test_authorizations.py, tests/e2e/catalog/authorizations/test_async_authorizations.py
Added new E2E test modules and fixtures covering create, get by ID, filter (RQLQuery), update notes, and 404 not-found assertions; includes resource lifecycle helpers for create/delete and async variants.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Areas to review closely:
    • buyer_factory and any fixtures depending on the removed local buyer_account_id in tests/e2e/accounts/buyers/conftest.py to ensure no missing dependency remains.
    • pricing_policy_data signature update and call sites to confirm correct parameter propagation.
    • authorization_data payload fields align with API expectations (required keys, types).
    • Async test helpers and cleanup paths in test_async_authorizations.py to ensure proper teardown.

Possibly related PRs

Suggested reviewers

  • d3rky
  • jentyk
  • svazquezco
  • ruben-sebrango

Poem

🐰 I hopped through fixtures, making one true root,
Authorizations sprouted — tests taking root,
Buyers now centralized, tidy and neat,
Async and sync bunny-steps, all tests complete,
A little hop, a quiet cheer — the suite is sweet.

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 pull request title accurately reflects the main objective: adding end-to-end tests for the catalog/authorizations API, with ticket reference MPT-14895.
✨ 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-14895-authorizations

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

@github-actions
Copy link

github-actions bot commented Dec 4, 2025

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

Generated by 🚫 dangerJS against 4397619

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7d33e5d and 96e0dda.

📒 Files selected for processing (6)
  • tests/e2e/accounts/buyers/conftest.py (0 hunks)
  • tests/e2e/catalog/authorizations/conftest.py (1 hunks)
  • tests/e2e/catalog/authorizations/test_async_authorizations.py (1 hunks)
  • tests/e2e/catalog/authorizations/test_authorizations.py (1 hunks)
  • tests/e2e/catalog/pricing_policies/conftest.py (1 hunks)
  • tests/e2e/conftest.py (1 hunks)
💤 Files with no reviewable changes (1)
  • tests/e2e/accounts/buyers/conftest.py
🧰 Additional context used
🧠 Learnings (1)
📚 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/conftest.py
🧬 Code graph analysis (2)
tests/e2e/catalog/authorizations/conftest.py (1)
tests/e2e/conftest.py (5)
  • mpt_ops (31-32)
  • product_id (96-97)
  • seller_id (127-128)
  • account_id (122-123)
  • short_uuid (101-102)
tests/e2e/catalog/pricing_policies/conftest.py (1)
tests/e2e/conftest.py (2)
  • buyer_account_id (137-138)
  • product_id (96-97)
🪛 GitHub Actions: PR build and merge
tests/e2e/catalog/authorizations/test_async_authorizations.py

[error] 1-6: I001 Import block is un-sorted or un-formatted. Organize imports. These issues are fixable with the '--fix' option.

tests/e2e/catalog/authorizations/test_authorizations.py

[error] 1-7: I001 Import block is un-sorted or un-formatted. Organize imports. These issues are fixable with the '--fix' option.

🪛 Ruff (0.14.7)
tests/e2e/catalog/authorizations/test_async_authorizations.py

23-23: Unused noqa directive (unknown: AAA01)

Remove unused noqa directive

(RUF100)

tests/e2e/catalog/authorizations/test_authorizations.py

24-24: Unused noqa directive (unknown: AAA01)

Remove unused noqa directive

(RUF100)

🔇 Additional comments (9)
tests/e2e/conftest.py (1)

136-138: LGTM! Fixture centralization improves maintainability.

The buyer_account_id fixture is now properly centralized at the root level, following the same pattern as other configuration-based fixtures in this file.

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

7-11: LGTM! Parameter rename aligns with centralized fixture.

The change from buyer_id to buyer_account_id correctly aligns with the centralized fixture added to the root conftest.py.

tests/e2e/catalog/authorizations/conftest.py (2)

4-6: LGTM! Service fixture follows standard pattern.

The authorizations_service fixture correctly provides access to the catalog authorizations service.


9-21: LGTM! Authorization data fixture is well-structured.

The authorization_data fixture provides a comprehensive test payload with all required fields for authorization testing.

tests/e2e/catalog/authorizations/test_async_authorizations.py (3)

10-20: LGTM! Async fixtures properly structured.

The async authorization fixtures correctly use async context managers for resource lifecycle management.


23-55: LGTM! Comprehensive async test coverage.

The tests cover all key operations (create, get, filter, update, not found) with proper async/await patterns and error handling.


23-23: Remove unused noqa directive.

The noqa: AAA01 directive is not recognized by the linter and should be removed.

Apply this diff:

-def test_create_authorization(created_authorization, authorization_data):  # noqa: AAA01
+def test_create_authorization(created_authorization, authorization_data):
⛔ Skipped due to learnings
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.586Z
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.
tests/e2e/catalog/authorizations/test_authorizations.py (2)

10-15: LGTM! Sync fixtures properly structured.

The authorization fixture correctly uses a context manager for resource lifecycle management.


18-48: LGTM! Comprehensive test coverage.

The tests cover all key operations (get, create, filter, update, not found) with proper synchronous patterns and error handling.

assert result.id == authorization_id


def test_create_authorization(created_authorization, authorization_data): # noqa: AAA01
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove unused noqa directive.

The noqa: AAA01 directive is not recognized by the linter and should be removed.

Apply this diff:

-def test_create_authorization(created_authorization, authorization_data):  # noqa: AAA01
+def test_create_authorization(created_authorization, authorization_data):
📝 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
def test_create_authorization(created_authorization, authorization_data): # noqa: AAA01
def test_create_authorization(created_authorization, authorization_data):
🧰 Tools
🪛 Ruff (0.14.7)

24-24: Unused noqa directive (unknown: AAA01)

Remove unused noqa directive

(RUF100)

🤖 Prompt for AI Agents
In tests/e2e/catalog/authorizations/test_authorizations.py around line 24, the
test definition includes an unused and unrecognized noqa directive "noqa:
AAA01"; remove the trailing ",  # noqa: AAA01" from the function signature so
the test line reads simply "def test_create_authorization(created_authorization,
authorization_data):" to eliminate the invalid linter directive.

@albertsola albertsola force-pushed the e2e/catalog/MPT-14895-authorizations branch from 96e0dda to bb6f776 Compare December 4, 2025 16:00
@albertsola albertsola force-pushed the e2e/catalog/MPT-14895-authorizations branch from bb6f776 to 4397619 Compare December 4, 2025 16:01
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

♻️ Duplicate comments (1)
tests/e2e/catalog/authorizations/test_authorizations.py (1)

24-24: Remove unused noqa directive.

The noqa: AAA01 directive remains unused and should be removed, as previously flagged.

Apply this diff:

-def test_create_authorization(created_authorization, authorization_data):  # noqa: AAA01
+def test_create_authorization(created_authorization, authorization_data):
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 96e0dda and 4397619.

📒 Files selected for processing (6)
  • tests/e2e/accounts/buyers/conftest.py (0 hunks)
  • tests/e2e/catalog/authorizations/conftest.py (1 hunks)
  • tests/e2e/catalog/authorizations/test_async_authorizations.py (1 hunks)
  • tests/e2e/catalog/authorizations/test_authorizations.py (1 hunks)
  • tests/e2e/catalog/pricing_policies/conftest.py (1 hunks)
  • tests/e2e/conftest.py (1 hunks)
💤 Files with no reviewable changes (1)
  • tests/e2e/accounts/buyers/conftest.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/e2e/catalog/authorizations/conftest.py
  • tests/e2e/catalog/pricing_policies/conftest.py
🧰 Additional context used
🧠 Learnings (2)
📚 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/conftest.py
📚 Learning: 2025-12-01T10:48:52.586Z
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.586Z
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/catalog/authorizations/test_authorizations.py
🪛 Ruff (0.14.7)
tests/e2e/catalog/authorizations/test_async_authorizations.py

23-23: Unused noqa directive (unknown: AAA01)

Remove unused noqa directive

(RUF100)

tests/e2e/catalog/authorizations/test_authorizations.py

24-24: Unused noqa directive (unknown: AAA01)

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 (3)
tests/e2e/conftest.py (1)

136-138: LGTM! Fixture follows established patterns.

The buyer_account_id fixture correctly centralizes access to the buyer account ID configuration value, consistent with other config-based fixtures in this file.

tests/e2e/catalog/authorizations/test_async_authorizations.py (1)

10-55: LGTM! Comprehensive async test coverage.

The test suite properly covers:

  • Authorization creation and cleanup via async context manager
  • GET operation with ID verification
  • Filtering with RQL queries and field selection
  • 404 error handling
  • Update operations with assertions

All async patterns are correctly implemented.

tests/e2e/catalog/authorizations/test_authorizations.py (1)

10-48: LGTM! Comprehensive synchronous test coverage.

The test suite mirrors the async version with proper synchronous patterns, covering:

  • Authorization creation and cleanup
  • GET operation
  • RQL filtering and field selection
  • Error handling for not-found scenarios
  • Update operations

The # act comment on line 48 appropriately marks the Act phase of the AAA test pattern.

Comment on lines +1 to +6
import pytest

from mpt_api_client.exceptions import MPTAPIError
from mpt_api_client.rql.query_builder import RQLQuery
from tests.e2e.helper import 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 | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

cat -n tests/e2e/catalog/authorizations/test_async_authorizations.py | head -30

Repository: softwareone-platform/mpt-api-python-client

Length of output: 1285


🏁 Script executed:

fd -t f -name "pyproject.toml" -o -name "ruff.toml" -o -name ".flake8" | head -10

Repository: softwareone-platform/mpt-api-python-client

Length of output: 316


🏁 Script executed:

rg "noqa" tests/e2e/catalog/authorizations/test_async_authorizations.py -n

Repository: softwareone-platform/mpt-api-python-client

Length of output: 177


🏁 Script executed:

cat pyproject.toml | grep -A 50 "\[tool.ruff\]" | head -80

Repository: softwareone-platform/mpt-api-python-client

Length of output: 1373


🏁 Script executed:

cat pyproject.toml | grep -i "flake8\|aaa01" -B 2 -A 2

Repository: softwareone-platform/mpt-api-python-client

Length of output: 1574


🏁 Script executed:

fd -t f "pyproject.toml" -exec grep -l "flake8-aaa\|AAA" {} \;

Repository: softwareone-platform/mpt-api-python-client

Length of output: 336


Remove unnecessary noqa: AAA01 directive on line 23.

The imports on lines 1–6 are correctly sorted (stdlib, third-party, local with proper blank line separators). However, line 23 has # noqa: AAA01 which is unnecessary. flake8-aaa is installed as a dev dependency but not enabled in the ruff configuration ([tool.ruff.lint] does not include "AAA" in the select list). Remove this noqa directive.

🤖 Prompt for AI Agents
In tests/e2e/catalog/authorizations/test_async_authorizations.py (lines 1–6),
remove the unnecessary "# noqa: AAA01" directive found on line 23; since the AAA
rule set is not enabled in the project Ruff config, delete that noqa comment,
save the file, and run the linter (ruff/flake8) to verify no remaining noqa for
AAA is required.

Comment on lines +23 to +24
def test_create_authorization(created_authorization, authorization_data): # noqa: AAA01
assert created_authorization.name == authorization_data["name"]
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove unused noqa directive.

The noqa: AAA01 directive is not recognized by the project's linter (Ruff) and should be removed.

Apply this diff:

-def test_create_authorization(created_authorization, authorization_data):  # noqa: AAA01
+def test_create_authorization(created_authorization, authorization_data):
📝 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
def test_create_authorization(created_authorization, authorization_data): # noqa: AAA01
assert created_authorization.name == authorization_data["name"]
def test_create_authorization(created_authorization, authorization_data):
assert created_authorization.name == authorization_data["name"]
🧰 Tools
🪛 Ruff (0.14.7)

23-23: Unused noqa directive (unknown: AAA01)

Remove unused noqa directive

(RUF100)

🤖 Prompt for AI Agents
In tests/e2e/catalog/authorizations/test_async_authorizations.py around lines 23
to 24, the test function contains an unused and unrecognized noqa directive `#
noqa: AAA01`; remove the `# noqa: AAA01` suffix from the function definition
line so the file no longer contains the invalid linter directive and the test
reads simply `def test_create_authorization(created_authorization,
authorization_data):` with the assertion unchanged.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 4, 2025

@albertsola albertsola merged commit ff6b291 into main Dec 4, 2025
6 of 7 checks passed
@albertsola albertsola deleted the e2e/catalog/MPT-14895-authorizations branch December 4, 2025 16:34
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