Skip to content

MPT-19906: add /integration/extensions/{id}/terms service#286

Merged
albertsola merged 2 commits intomainfrom
MPT-19906/integration-extension-terms
Apr 9, 2026
Merged

MPT-19906: add /integration/extensions/{id}/terms service#286
albertsola merged 2 commits intomainfrom
MPT-19906/integration-extension-terms

Conversation

@albertsola
Copy link
Copy Markdown
Contributor

@albertsola albertsola commented Apr 7, 2026

Summary

Implements the /public/v1/integration/extensions/{extensionId}/terms endpoint group as part of MPT-13310.

Changes

  • mpt_api_client/resources/integration/extension_terms.py — PublishableMixin + ManagedResourceMixin + CollectionMixin; exposes variants(term_id) accessor
  • mpt_api_client/resources/integration/extension_term_variants.py — stub only (full impl in MPT-19907)
  • Updated extensions.py to expose terms(extension_id) accessor
  • Unit tests: tests/unit/resources/integration/test_extension_terms.py
  • E2e tests: tests/e2e/integration/extension_terms/

Depends on

#277 (MPT-19892 — rename extensibility → integration)

⚠️ Draft — targets MPT-19892/e2e-extension-base-service until PR #277 merges.

Closes MPT-19906

  • Implement /public/v1/integration/extensions/{extensionId}/terms API resource with ExtensionTermsService and AsyncExtensionTermsService
  • Add ExtensionTerm model (name, revision, description, display_order, status, extension, audit)
  • Compose PublishableMixin, ManagedResourceMixin, and CollectionMixin into terms services to support CRUD, publish/unpublish, and collection operations
  • Expose variants(term_id) accessor on terms services to return scoped ExtensionTermVariantsService / AsyncExtensionTermVariantsService
  • Add stub ExtensionTermVariantsService and AsyncExtensionTermVariantsService for /terms/{termId}/variants (full implementation deferred to MPT-19907)
  • Introduce PublishableMixin and AsyncPublishableMixin providing publish/unpublish methods
  • Update ExtensionsService and AsyncExtensionsService to expose terms(extension_id) accessor
  • Add unit tests for service mixins, nested accessors, and model serialization
  • Add E2E tests (sync + async) covering create, filter, update, publish, unpublish, delete workflows and related fixtures
  • Update e2e test config: change integration.extension.id in e2e_config.test.json from EXT-4401-0953 to EXT-6587-4477
  • Note: branch depends on PR MPT-19892: add E2E tests for Extension base service - Includes renaming from extensibility -> integrations #277 (MPT-19892 — rename extensibility → integration) and currently targets its branch until that dependency merges

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 7, 2026

📝 Walkthrough

Walkthrough

Adds ExtensionTerm and ExtensionTermVariant models, sync/async services, a PublishableMixin, extensions.terms(...) accessors, updates an e2e config value, and introduces unit and E2E tests covering create/filter/update/publish/unpublish/delete flows.

Changes

Cohort / File(s) Summary
Configuration
e2e_config.test.json
Updated integration.extension.id from EXT-4401-0953 to EXT-6587-4477.
New resources & services
mpt_api_client/resources/integration/extension_terms.py, mpt_api_client/resources/integration/extension_term_variants.py
Added ExtensionTerm and ExtensionTermVariant models plus typed sync/async service classes; ExtensionTermsService exposes variants(term_id) to return the nested variants service.
Extensions service integration
mpt_api_client/resources/integration/extensions.py
Added terms(extension_id) methods to ExtensionsService and AsyncExtensionsService to return terms services with endpoint params.
Publishable mixin
mpt_api_client/resources/integration/mixins/publishable_mixin.py, mpt_api_client/resources/integration/mixins/__init__.py
Introduced PublishableMixin and AsyncPublishableMixin with publish/unpublish methods and exported them from the mixins package.
E2E tests (sync & async)
tests/e2e/integration/extension_terms/conftest.py, tests/e2e/integration/extension_terms/test_sync_extension_terms.py, tests/e2e/integration/extension_terms/test_async_extension_terms.py
Added fixtures and tests exercising term lifecycle: create, filter, update, publish, unpublish, delete for both sync and async services.
Unit tests
tests/unit/resources/integration/test_extension_terms.py, tests/unit/resources/integration/mixins/test_publishable_mixin.py
Added unit tests for models, service composition, nested accessors, and publish/unpublish behavior (including HTTP request assertions).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Jira Issue Key In Title ✅ Passed PR title contains exactly one Jira issue key in format MPT-XXXX: MPT-19906.
Test Coverage Required ✅ Passed The PR modifies 6 code files in the mpt_api_client directory and configuration files, and includes 5 new test files in the tests/ folder covering both unit and E2E scenarios. Since test files are included alongside the code changes, the test coverage requirement is satisfied.
Single Commit Required ✅ Passed The PR contains exactly one commit (d429f76) with all changes properly consolidated, meeting the single commit requirement.

✏️ 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.

Base automatically changed from MPT-19892/e2e-extension-base-service to main April 7, 2026 12:00
@albertsola albertsola force-pushed the MPT-19906/integration-extension-terms branch from be2da71 to fc378ce Compare April 7, 2026 12:05
…endpoint

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@albertsola albertsola force-pushed the MPT-19906/integration-extension-terms branch 2 times, most recently from ad6f288 to 7222c15 Compare April 9, 2026 10:45
@albertsola albertsola marked this pull request as ready for review April 9, 2026 10:45
@albertsola albertsola requested a review from a team as a code owner April 9, 2026 10:45
@albertsola albertsola requested review from alephsur and jentyk April 9, 2026 10:45
@albertsola albertsola marked this pull request as draft April 9, 2026 10:47
Copy link
Copy Markdown

@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.

🧹 Nitpick comments (3)
tests/unit/resources/integration/test_extension_terms.py (1)

90-94: Remove redundant test_extension_term_create assertion.

create is already covered by the parametrized mixin-presence tests, so this test can be dropped to reduce duplication.

♻️ Suggested cleanup
-def test_extension_term_create(terms_service: ExtensionTermsService) -> None:
-    result = hasattr(terms_service, "create")
-
-    assert result is True
-
-
 def test_extension_terms_variants_accessor(terms_service: ExtensionTermsService) -> None:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/unit/resources/integration/test_extension_terms.py` around lines 90 -
94, Remove the redundant test function test_extension_term_create that only
checks hasattr(terms_service, "create"); locate the test function named
test_extension_term_create in the
tests/unit/resources/integration/test_extension_terms.py file and delete it (the
behavior is already covered by the parametrized mixin-presence tests), ensuring
no other tests reference that function name.
tests/e2e/integration/extension_terms/test_async_extension_terms.py (1)

44-45: Strengthen delete test with an explicit outcome check.

Consider asserting the term is no longer retrievable after delete to ensure the test verifies behavior, not only lack of exception.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/integration/extension_terms/test_async_extension_terms.py` around
lines 44 - 45, The delete test currently only calls
async_extension_terms_service.delete(async_created_term.id) without verifying
outcome; update test_delete_extension_term to assert the term was actually
removed by attempting to retrieve it after deletion (call
async_extension_terms_service.get or list by id) and assert the call either
raises the expected NotFound/KeyError or returns None/empty result for
async_created_term.id; use the same async_extension_terms_service.delete and
async_created_term.id symbols to locate and modify the test.
tests/e2e/integration/extension_terms/test_sync_extension_terms.py (1)

42-43: Add a post-delete verification to prevent false positives.

This test currently passes if delete() returns without raising, even if the resource remains. Add a follow-up assertion (e.g., filtered result is empty or fetch by id fails) to verify the deletion outcome.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/integration/extension_terms/test_sync_extension_terms.py` around
lines 42 - 43, The test test_delete_extension_term only calls
extension_terms_service.delete(created_term.id) but lacks verification; after
calling extension_terms_service.delete(created_term.id) add an assertion that
the term is actually gone by either calling
extension_terms_service.get(created_term.id) and asserting it raises/returns
None, or calling extension_terms_service.list(filter_by_id=created_term.id) /
extension_terms_service.filter(...) and asserting the result is empty; update
references to created_term.id and use the service's existing get/list/filter
methods (or expected exception) to verify deletion.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/e2e/integration/extension_terms/test_async_extension_terms.py`:
- Around line 44-45: The delete test currently only calls
async_extension_terms_service.delete(async_created_term.id) without verifying
outcome; update test_delete_extension_term to assert the term was actually
removed by attempting to retrieve it after deletion (call
async_extension_terms_service.get or list by id) and assert the call either
raises the expected NotFound/KeyError or returns None/empty result for
async_created_term.id; use the same async_extension_terms_service.delete and
async_created_term.id symbols to locate and modify the test.

In `@tests/e2e/integration/extension_terms/test_sync_extension_terms.py`:
- Around line 42-43: The test test_delete_extension_term only calls
extension_terms_service.delete(created_term.id) but lacks verification; after
calling extension_terms_service.delete(created_term.id) add an assertion that
the term is actually gone by either calling
extension_terms_service.get(created_term.id) and asserting it raises/returns
None, or calling extension_terms_service.list(filter_by_id=created_term.id) /
extension_terms_service.filter(...) and asserting the result is empty; update
references to created_term.id and use the service's existing get/list/filter
methods (or expected exception) to verify deletion.

In `@tests/unit/resources/integration/test_extension_terms.py`:
- Around line 90-94: Remove the redundant test function
test_extension_term_create that only checks hasattr(terms_service, "create");
locate the test function named test_extension_term_create in the
tests/unit/resources/integration/test_extension_terms.py file and delete it (the
behavior is already covered by the parametrized mixin-presence tests), ensuring
no other tests reference that function name.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: 1cd09ec3-68b8-4426-accf-152a8685b74c

📥 Commits

Reviewing files that changed from the base of the PR and between a6b5f31 and 7222c15.

📒 Files selected for processing (11)
  • e2e_config.test.json
  • mpt_api_client/resources/integration/extension_term_variants.py
  • mpt_api_client/resources/integration/extension_terms.py
  • mpt_api_client/resources/integration/extensions.py
  • mpt_api_client/resources/integration/mixins/__init__.py
  • mpt_api_client/resources/integration/mixins/publishable_mixin.py
  • tests/e2e/integration/extension_terms/__init__.py
  • tests/e2e/integration/extension_terms/conftest.py
  • tests/e2e/integration/extension_terms/test_async_extension_terms.py
  • tests/e2e/integration/extension_terms/test_sync_extension_terms.py
  • tests/unit/resources/integration/test_extension_terms.py

…sionId}/terms

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@albertsola albertsola force-pushed the MPT-19906/integration-extension-terms branch from 7222c15 to d429f76 Compare April 9, 2026 14:11
@albertsola albertsola marked this pull request as ready for review April 9, 2026 14:11
@albertsola albertsola self-assigned this Apr 9, 2026
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 9, 2026

Copy link
Copy Markdown

@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.

🧹 Nitpick comments (1)
tests/unit/resources/integration/mixins/test_publishable_mixin.py (1)

42-137: Consider reducing duplication across sync/async action tests.

The request mock setup and assertions are repeated in four tests. Extracting shared helpers (route setup + common assertions) would make future endpoint/action updates less error-prone.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/unit/resources/integration/mixins/test_publishable_mixin.py` around
lines 42 - 137, The tests duplicate route setup and assertions across
test_action_with_data, test_action_no_data, test_async_action_with_data, and
test_async_action_no_data; refactor by extracting reusable helpers: (1) a
setup_route(action, expected_response) helper that creates and returns the respx
mock_route used in all tests, and (2) an assert_request_post(mock_route,
expected_content) helper that checks mock_route.call_count, request.method and
request.content and optionally validates result type/structure; update calls in
publishable_service and async_publishable_service tests to use these helpers to
reduce duplication while keeping the same behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/unit/resources/integration/mixins/test_publishable_mixin.py`:
- Around line 42-137: The tests duplicate route setup and assertions across
test_action_with_data, test_action_no_data, test_async_action_with_data, and
test_async_action_no_data; refactor by extracting reusable helpers: (1) a
setup_route(action, expected_response) helper that creates and returns the respx
mock_route used in all tests, and (2) an assert_request_post(mock_route,
expected_content) helper that checks mock_route.call_count, request.method and
request.content and optionally validates result type/structure; update calls in
publishable_service and async_publishable_service tests to use these helpers to
reduce duplication while keeping the same behavior.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: 8992d936-f4f1-4c08-9027-255c2141bdf3

📥 Commits

Reviewing files that changed from the base of the PR and between 7222c15 and d429f76.

📒 Files selected for processing (6)
  • e2e_config.test.json
  • tests/e2e/integration/extension_terms/__init__.py
  • tests/e2e/integration/extension_terms/conftest.py
  • tests/e2e/integration/extension_terms/test_async_extension_terms.py
  • tests/e2e/integration/extension_terms/test_sync_extension_terms.py
  • tests/unit/resources/integration/mixins/test_publishable_mixin.py
✅ Files skipped from review due to trivial changes (1)
  • e2e_config.test.json
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/e2e/integration/extension_terms/test_sync_extension_terms.py
  • tests/e2e/integration/extension_terms/test_async_extension_terms.py

@albertsola albertsola merged commit 61193fd into main Apr 9, 2026
4 checks passed
@albertsola albertsola deleted the MPT-19906/integration-extension-terms branch April 9, 2026 14:21
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.

2 participants