Skip to content

MPT-19907: add /integration/extensions/{id}/terms/{termId}/variants service#287

Merged
albertsola merged 3 commits intomainfrom
MPT-19907/integration-extension-term-variants
Apr 13, 2026
Merged

MPT-19907: add /integration/extensions/{id}/terms/{termId}/variants service#287
albertsola merged 3 commits intomainfrom
MPT-19907/integration-extension-term-variants

Conversation

@albertsola
Copy link
Copy Markdown
Contributor

@albertsola albertsola commented Apr 7, 2026

Summary

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

Changes

  • mpt_api_client/resources/integration/extension_term_variants.py — full impl replacing stub from MPT-19906: PublishableMixin + CreateFileMixin + ModifiableResourceMixin + CollectionMixin
  • ExtensionTermVariant model with all OpenAPI fields (type, assetUrl, languageCode, description, filename, size, contentType, term, fileId)
  • Unit tests: tests/unit/resources/integration/test_extension_term_variants.py
  • E2e tests: tests/e2e/integration/extension_term_variants/

Depends on

#286 (MPT-19906 — extension terms, which contains the stub this PR replaces)

⚠️ Draft — targets MPT-19906/integration-extension-terms; rebase chain: MPT-19906 → MPT-19907.

Closes MPT-19907

  • Implements the /public/v1/integration/extensions/{extensionId}/terms/{termId}/variants endpoint group with create (including file upload), read, update, delete, publish, and unpublish operations
  • Adds ExtensionTermVariant model with typed attributes (type, assetUrl, languageCode, description, filename, size, contentType, term, fileId, plus common metadata)
  • Implements ExtensionTermVariantsService (sync + async) including PublishableMixin, CreateFileMixin, ModifiableResourceMixin, and CollectionMixin; configures upload keys (_upload_file_key="file", _upload_data_key="variant")
  • Replaces stub with full resource implementation at mpt_api_client/resources/integration/extension_term_variants.py
  • Adds unit tests for service methods, model parsing, HTTP behavior, and endpoint/path construction
  • Adds end-to-end tests (sync and async) for create (PDF upload), filter/iterate, update, publish, unpublish, and delete; includes e2e fixtures and teardown logic
  • Updates e2e test config to include integration.term.id
  • Draft: targets the rebase chain MPT-19906 → MPT-19907 (depends on MPT-19906)

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: 2ee794cc-4c64-4915-8475-50dec7ec10c2

📥 Commits

Reviewing files that changed from the base of the PR and between 7137da8 and 8976551.

📒 Files selected for processing (4)
  • e2e_config.test.json
  • tests/e2e/integration/extension_term_variants/conftest.py
  • tests/e2e/integration/extension_term_variants/test_async_extension_term_variants.py
  • tests/e2e/integration/extension_term_variants/test_sync_extension_term_variants.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 (1)
  • tests/e2e/integration/extension_term_variants/test_async_extension_term_variants.py

📝 Walkthrough

Walkthrough

Added a new integration term ID to test config; extended the ExtensionTermVariant model with typed attributes and upload keys; broadened sync/async service classes with publish/create-file/modify mixins; and introduced unit and E2E tests plus E2E fixtures for extension term variants.

Changes

Cohort / File(s) Summary
Configuration
e2e_config.test.json
Added new required key integration.term.id with value ETC-6587-4477-0062. Kept integration.extension.id as EXT-6587-4477.
Service Implementation
mpt_api_client/resources/integration/extension_term_variants.py
Expanded ExtensionTermVariant with explicit typed attributes (name, revision, type, asset_url, language_code, description, status, filename, size, content_type, term, file_id, audit). Added upload config keys (_upload_file_key="file", _upload_data_key="variant") and extended service classes to include PublishableMixin, CreateFileMixin, ModifiableResourceMixin (and async equivalents).
E2E Test Fixtures
tests/e2e/integration/extension_term_variants/conftest.py
Added pytest fixtures: session-scoped extension_id and term_id from e2e_config, sync/async service fixtures, variant_data, and lifecycle fixtures created_variant/async_created_variant that create then teardown variants.
E2E Test Suites
tests/e2e/integration/extension_term_variants/test_sync_extension_term_variants.py, tests/e2e/integration/extension_term_variants/test_async_extension_term_variants.py
Added sync and async E2E tests exercising create, filter/iterate, update, publish, unpublish, and delete behaviors; module-level flaky marker applied.
Unit Test Suite
tests/unit/resources/integration/test_extension_term_variants.py
Added unit tests verifying service method exposure, model parsing/serialization (including nested term/audit as BaseModel), HTTP interactions via respx for create/get/list, and endpoint/path construction.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 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-19907) in the correct format MPT-XXXX.
Test Coverage Required ✅ Passed PR modifies 1 code file and includes 4 test files, meeting the requirement that test files be included when code files are modified.
Single Commit Required ✅ Passed The PR contains exactly one commit consolidating all changes for the /integration/extensions/{id}/terms/{termId}/variants endpoint implementation.

✏️ 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 MPT-19906/integration-extension-terms branch from be2da71 to fc378ce Compare April 7, 2026 12:05
@albertsola albertsola force-pushed the MPT-19907/integration-extension-term-variants branch from 4f57246 to 0e66010 Compare April 7, 2026 12:05
@albertsola albertsola force-pushed the MPT-19906/integration-extension-terms branch 3 times, most recently from 7222c15 to d429f76 Compare April 9, 2026 14:11
Base automatically changed from MPT-19906/integration-extension-terms to main April 9, 2026 14:21
albertsola and others added 2 commits April 10, 2026 13:30
…{termId}/variants endpoint

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…sionId}/terms/{termId}/variants

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@albertsola albertsola force-pushed the MPT-19907/integration-extension-term-variants branch from 0e66010 to 7137da8 Compare April 10, 2026 12:37
@albertsola albertsola marked this pull request as ready for review April 10, 2026 12:37
@albertsola albertsola requested a review from a team as a code owner April 10, 2026 12:38
@albertsola albertsola requested review from d3rky and svazquezco April 10, 2026 12:38
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.

Actionable comments posted: 1

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

97-122: Assert the multipart request contract in the create test.

This test currently proves only that a POST happened and that the mocked response was parsed. It would still pass if the multipart body used the wrong part names or wrong field casing. Since CreateFileMixin relies on "file" and "variant", this test should verify the outgoing request and keep the payload shape aligned with the endpoint’s camelCase contract.

Suggested change
     variant_payload = {
-        "Type": "File",
-        "Name": "English Variant",
-        "LanguageCode": "en-US",
-        "Description": "English language variant",
+        "type": "File",
+        "name": "English Variant",
+        "languageCode": "en-US",
+        "description": "English language variant",
     }
@@
     assert mock_route.call_count == 1
+    request = mock_route.calls[0].request
+    assert b'name="variant"' in request.content
+    assert b'name="file"' in request.content
+    assert b'"languageCode":"en-US"' in request.content
     assert result.to_dict() == response_data
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/unit/resources/integration/test_extension_term_variants.py` around
lines 97 - 122, Update the test_extension_term_variant_create to assert the
outgoing multipart request uses the expected part names and payload casing:
after calling variants_service.create(…) inspect mock_route.calls[0].request to
verify the multipart body contains a "file" part and a "variant" part (not
"File" or other casing) and that the "variant" part JSON payload uses camelCase
keys ("Type" -> "type", "Name" -> "name", "LanguageCode" -> "languageCode",
"Description" -> "description") to match CreateFileMixin and the endpoint
contract; keep the existing respx/httpx mock and response assertions but add
these explicit checks against mock_route.calls[0].request content so the test
fails if part names or payload shape are incorrect.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/e2e/integration/extension_term_variants/conftest.py`:
- Around line 11-23: Add a new session-scoped fixture variant_id (backed by
e2e_config["integration.term_variant.id"]) and expose it alongside term_id;
update the existing fixtures/consumers to use this seeded variant_id for
read-only enabled-filter tests instead of using term_id so RQLQuery(id=...)
targets an actual variant. Specifically, add a fixture named variant_id and
change any tests that call extension_term_variants_service /
async_extension_term_variants_service filters to pass/consume variant_id (not
term_id) for the enabled assertions.

---

Nitpick comments:
In `@tests/unit/resources/integration/test_extension_term_variants.py`:
- Around line 97-122: Update the test_extension_term_variant_create to assert
the outgoing multipart request uses the expected part names and payload casing:
after calling variants_service.create(…) inspect mock_route.calls[0].request to
verify the multipart body contains a "file" part and a "variant" part (not
"File" or other casing) and that the "variant" part JSON payload uses camelCase
keys ("Type" -> "type", "Name" -> "name", "LanguageCode" -> "languageCode",
"Description" -> "description") to match CreateFileMixin and the endpoint
contract; keep the existing respx/httpx mock and response assertions but add
these explicit checks against mock_route.calls[0].request content so the test
fails if part names or payload shape are incorrect.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: e0301964-2a1f-4793-ac2f-2e3bbc58fe40

📥 Commits

Reviewing files that changed from the base of the PR and between 8e273bc and 7137da8.

📒 Files selected for processing (7)
  • e2e_config.test.json
  • mpt_api_client/resources/integration/extension_term_variants.py
  • tests/e2e/integration/extension_term_variants/__init__.py
  • tests/e2e/integration/extension_term_variants/conftest.py
  • tests/e2e/integration/extension_term_variants/test_async_extension_term_variants.py
  • tests/e2e/integration/extension_term_variants/test_sync_extension_term_variants.py
  • tests/unit/resources/integration/test_extension_term_variants.py

Comment thread tests/e2e/integration/extension_term_variants/conftest.py Outdated
@albertsola albertsola force-pushed the MPT-19907/integration-extension-term-variants branch from 7137da8 to 66c672a Compare April 13, 2026 08:48
@albertsola albertsola force-pushed the MPT-19907/integration-extension-term-variants branch from 66c672a to 8976551 Compare April 13, 2026 08:49
@sonarqubecloud
Copy link
Copy Markdown

@albertsola albertsola merged commit b14414e into main Apr 13, 2026
4 checks passed
@albertsola albertsola deleted the MPT-19907/integration-extension-term-variants branch April 13, 2026 13:12
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