Skip to content

MPT-19904: add /integration/extensions/{id}/documents service#284

Merged
albertsola merged 4 commits intomainfrom
MPT-19904/integration-extension-documents
Apr 10, 2026
Merged

MPT-19904: add /integration/extensions/{id}/documents service#284
albertsola merged 4 commits intomainfrom
MPT-19904/integration-extension-documents

Conversation

@albertsola
Copy link
Copy Markdown
Contributor

@albertsola albertsola commented Apr 7, 2026

Summary

Implements the /public/v1/integration/extensions/{extensionId}/documents endpoint group.

Changes

  • mpt_api_client/resources/integration/extension_documents.pyPublishableMixin + CreateFileMixin + ModifiableResourceMixin + CollectionMixin
  • mpt_api_client/resources/integration/mixins/publishable_mixin.pypublish/unpublish mixin (no review; differs from catalog variant)
  • mpt_api_client/resources/integration/extensions.py — added documents(extension_id) accessor to both sync and async services; rebased on main (includes MPT-19906 terms accessor)
  • Unit tests: 100% coverage on all new code
    • tests/unit/resources/integration/test_extension_documents.py
    • tests/unit/resources/integration/mixins/test_publishable_mixin.py
  • E2E tests: tests/e2e/integration/extension_documents/

QA

  • make check-all: all linting (ruff, flake8, mypy) + 1889 tests pass ✅
  • publishable_mixin.py: 100% coverage ✅
  • extension_documents.py: 100% coverage ✅

Closes MPT-19904

  • Implement /public/v1/integration/extensions/{extensionId}/documents with sync and async services
  • Add ExtensionDocument model (metadata + file attributes) and ExtensionDocumentsService / AsyncExtensionDocumentsService
  • Add PublishableMixin for publish/unpublish (integration variant, no review flow)
  • Implement create-file (upload), ModifiableResourceMixin and CollectionMixin behavior for document operations
  • Add download support for extension documents
  • Expose documents(extension_id) accessor on ExtensionsService and AsyncExtensionsService
  • Tests: unit tests (100% coverage for new files) and E2E tests covering create, filter, update, publish, unpublish, download, and delete
  • QA: ruff, flake8, mypy checks and test suite run (1889 tests) passed
  • Commit: "MPT-19904: add download support and tests for extension documents" (includes Co-authored-by: Copilot)

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: da56bf14-1481-42da-9ba3-e14de3edef50

📥 Commits

Reviewing files that changed from the base of the PR and between 82b4ff1 and 74b9933.

📒 Files selected for processing (7)
  • mpt_api_client/resources/integration/extension_documents.py
  • mpt_api_client/resources/integration/extensions.py
  • tests/e2e/integration/extension_documents/__init__.py
  • tests/e2e/integration/extension_documents/conftest.py
  • tests/e2e/integration/extension_documents/test_async_extension_documents.py
  • tests/e2e/integration/extension_documents/test_sync_extension_documents.py
  • tests/unit/resources/integration/test_extension_documents.py
🚧 Files skipped from review as they are similar to previous changes (4)
  • mpt_api_client/resources/integration/extensions.py
  • tests/e2e/integration/extension_documents/test_async_extension_documents.py
  • tests/e2e/integration/extension_documents/test_sync_extension_documents.py
  • tests/unit/resources/integration/test_extension_documents.py

📝 Walkthrough

Walkthrough

Adds an ExtensionDocument model, config, and sync/async ExtensionDocumentsService for per-extension document CRUD, upload/download, publish/unpublish, wires documents(extension_id) accessors on ExtensionsService/AsyncExtensionsService, and introduces unit and e2e (sync & async) tests for the document lifecycle.

Changes

Cohort / File(s) Summary
Extension Document Resource
mpt_api_client/resources/integration/extension_documents.py
Adds ExtensionDocument model, ExtensionDocumentsServiceConfig, ExtensionDocumentsService, and AsyncExtensionDocumentsService for /public/v1/integration/extensions/{extension_id}/documents, supporting create (file upload), get, update, delete, download, publish/unpublish, and collection iteration.
Service Integration
mpt_api_client/resources/integration/extensions.py
Adds documents(extension_id: str) on ExtensionsService and AsyncExtensionsService to return configured documents service instances; imports document service types.
E2E Test Fixtures
tests/e2e/integration/extension_documents/conftest.py
New pytest fixtures: extension_id, sync/async document service fixtures, document_data, and lifecycle fixtures created_document / async_created_document that create (upload) and teardown documents.
E2E Sync Tests
tests/e2e/integration/extension_documents/test_sync_extension_documents.py
Flaky-marked tests for create, filter/iterate, update, publish, unpublish, download, and delete using sync fixtures.
E2E Async Tests
tests/e2e/integration/extension_documents/test_async_extension_documents.py
Flaky-marked async tests mirroring the sync suite (create, filter/iterate, update, publish, unpublish, download, delete) using async fixtures.
Unit Tests
tests/unit/resources/integration/test_extension_documents.py
Unit tests for service path resolution, presence of mixin methods on sync/async services, ExtensionDocument model serialization/nested BaseModel materialization, mocked HTTP POST file upload (respx), and accessor returns for extensions_service.documents(...).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Single Commit Required ❓ Inconclusive Cannot execute shell commands or access git repository. Unable to verify commit count requirement. Please run git log commands locally to verify the PR contains a single commit.
✅ Passed checks (2 passed)
Check name Status Explanation
Jira Issue Key In Title ✅ Passed The PR title contains exactly one Jira issue key in the format MPT-XXXX: MPT-19904.
Test Coverage Required ✅ Passed The PR modifies code files in mpt_api_client/resources/integration/ and includes comprehensive test coverage in multiple test directories with 100% coverage.

✏️ 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-19904/integration-extension-documents branch 4 times, most recently from af22a72 to 2bb3d5a Compare April 9, 2026 09:58
@albertsola albertsola marked this pull request as ready for review April 9, 2026 09:59
@albertsola albertsola requested a review from a team as a code owner April 9, 2026 09:59
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/e2e/integration/extension_documents/test_sync_extension_documents.py (1)

44-45: Isolate the destructive delete test from the auto-cleanup fixture.

Using created_document here triggers a second delete during fixture teardown, which adds avoidable teardown noise.

♻️ Proposed change
-def test_delete_extension_document(extension_documents_service, created_document):
-    extension_documents_service.delete(created_document.id)  # act
+def test_delete_extension_document(extension_documents_service, document_data):
+    document = extension_documents_service.create(document_data)
+    extension_documents_service.delete(document.id)  # act
Based on learnings: In end-to-end tests, reserve isolated fixtures/resources for destructive tests that require per-test creation and cleanup.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/integration/extension_documents/test_sync_extension_documents.py`
around lines 44 - 45, The test_delete_extension_document uses the shared
created_document fixture which will be auto-deleted in teardown, causing a
double-delete; change the test to create and manage its own document locally
instead of using created_document: call extension_documents_service.create(...)
at the start of test_delete_extension_document to obtain a new document id, call
extension_documents_service.delete(id) for the assertion, and let the
test-created resource be cleaned up or explicitly avoid relying on the shared
auto-cleanup fixture; reference the test name test_delete_extension_document and
the service extension_documents_service when making this change.
🤖 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_documents/test_sync_extension_documents.py`:
- Around line 44-45: The test_delete_extension_document uses the shared
created_document fixture which will be auto-deleted in teardown, causing a
double-delete; change the test to create and manage its own document locally
instead of using created_document: call extension_documents_service.create(...)
at the start of test_delete_extension_document to obtain a new document id, call
extension_documents_service.delete(id) for the assertion, and let the
test-created resource be cleaned up or explicitly avoid relying on the shared
auto-cleanup fixture; reference the test name test_delete_extension_document and
the service extension_documents_service when making this change.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: 938e1901-fd35-4731-893e-066889e7b588

📥 Commits

Reviewing files that changed from the base of the PR and between a6b5f31 and 2bb3d5a.

📒 Files selected for processing (11)
  • e2e_config.test.json
  • mpt_api_client/resources/integration/extension_documents.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_documents/__init__.py
  • tests/e2e/integration/extension_documents/conftest.py
  • tests/e2e/integration/extension_documents/test_async_extension_documents.py
  • tests/e2e/integration/extension_documents/test_sync_extension_documents.py
  • tests/unit/resources/integration/mixins/test_publishable_mixin.py
  • tests/unit/resources/integration/test_extension_documents.py

@albertsola albertsola self-assigned this Apr 9, 2026
@albertsola albertsola force-pushed the MPT-19904/integration-extension-documents branch from 2bb3d5a to 7586715 Compare April 10, 2026 08:05
albertsola and others added 4 commits April 10, 2026 12:57
…nts endpoint

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

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@albertsola albertsola force-pushed the MPT-19904/integration-extension-documents branch from 82b4ff1 to 74b9933 Compare April 10, 2026 11:59
@sonarqubecloud
Copy link
Copy Markdown

@albertsola albertsola merged commit 8e273bc into main Apr 10, 2026
4 checks passed
@albertsola albertsola deleted the MPT-19904/integration-extension-documents branch April 10, 2026 12:20
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.

3 participants