MPT-19907: add /integration/extensions/{id}/terms/{termId}/variants service#287
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdded 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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
be2da71 to
fc378ce
Compare
4f57246 to
0e66010
Compare
7222c15 to
d429f76
Compare
…{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>
0e66010 to
7137da8
Compare
There was a problem hiding this comment.
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
CreateFileMixinrelies 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
📒 Files selected for processing (7)
e2e_config.test.jsonmpt_api_client/resources/integration/extension_term_variants.pytests/e2e/integration/extension_term_variants/__init__.pytests/e2e/integration/extension_term_variants/conftest.pytests/e2e/integration/extension_term_variants/test_async_extension_term_variants.pytests/e2e/integration/extension_term_variants/test_sync_extension_term_variants.pytests/unit/resources/integration/test_extension_term_variants.py
7137da8 to
66c672a
Compare
66c672a to
8976551
Compare
|



Summary
Implements the
/public/v1/integration/extensions/{extensionId}/terms/{termId}/variantsendpoint 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 + CollectionMixinExtensionTermVariantmodel with all OpenAPI fields (type, assetUrl, languageCode, description, filename, size, contentType, term, fileId)tests/unit/resources/integration/test_extension_term_variants.pytests/e2e/integration/extension_term_variants/Depends on
#286 (MPT-19906 — extension terms, which contains the stub this PR replaces)
Closes MPT-19907