MPT-19908: add /integration/installations service#281
MPT-19908: add /integration/installations service#281albertsola wants to merge 2 commits intomainfrom
Conversation
📝 WalkthroughWalkthroughAdds an "installations" integration resource: new Installation model, sync/async service classes, installation mixins (redeem/renew/token/token_for_account), integration wiring, unit and E2E tests, Flake8 ignore entries, and small E2E fixture/test and config updates. ChangesInstallation Resource and Tests
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Comment |
7d07055 to
f58b8f7
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/unit/resources/integration/mixins/test_installation_mixin.py (1)
46-66: Consider adding one case that verifies JSON payload forwarding.These tests currently validate action routing and response parsing, but not that
resource_datais sent through topost(..., json=...). Adding one payload case (sync + async) would close that gap.Also applies to: 72-91
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/unit/resources/integration/mixins/test_installation_mixin.py` around lines 46 - 66, Add a test variant that checks the request JSON payload is forwarded: in the test_post_actions function (and the async counterpart if present), include a resource_data dict and call getattr(installation_service, action)(installation_id, resource_data=resource_data) (or await for async), then assert the mocked respx.post received json==resource_data (e.g., inspect mock_route.calls[0].request.read() or .json()) and keep existing assertions on method, call_count, and response parsing to ensure post(..., json=...) is used.
🤖 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/extensions/test_async_extensions.py`:
- Around line 9-11: The test file has three consecutive blank lines before the
top-level test function test_create_extension causing ruff format --check to
fail; edit the file to remove one blank line so there are exactly two blank
lines separating top-level definitions (ensure there are two blank lines
immediately before def test_create_extension and no leftover `@pytest.mark.skip`
or stray blank lines).
---
Nitpick comments:
In `@tests/unit/resources/integration/mixins/test_installation_mixin.py`:
- Around line 46-66: Add a test variant that checks the request JSON payload is
forwarded: in the test_post_actions function (and the async counterpart if
present), include a resource_data dict and call getattr(installation_service,
action)(installation_id, resource_data=resource_data) (or await for async), then
assert the mocked respx.post received json==resource_data (e.g., inspect
mock_route.calls[0].request.read() or .json()) and keep existing assertions on
method, call_count, and response parsing to ensure post(..., json=...) is used.
🪄 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: 7638d5c8-b871-4f3d-b269-3aec3a657875
📒 Files selected for processing (16)
e2e_config.test.jsonmpt_api_client/resources/integration/installations.pympt_api_client/resources/integration/integration.pympt_api_client/resources/integration/mixins/__init__.pympt_api_client/resources/integration/mixins/installation_mixin.pypyproject.tomltests/e2e/integration/extensions/conftest.pytests/e2e/integration/extensions/test_async_extensions.pytests/e2e/integration/extensions/test_sync_extensions.pytests/e2e/integration/installations/__init__.pytests/e2e/integration/installations/conftest.pytests/e2e/integration/installations/test_async_installations.pytests/e2e/integration/installations/test_sync_installations.pytests/unit/resources/integration/mixins/test_installation_mixin.pytests/unit/resources/integration/test_installations.pytests/unit/resources/integration/test_integration.py
💤 Files with no reviewable changes (1)
- tests/e2e/integration/extensions/test_sync_extensions.py
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> � Conflicts: � mpt_api_client/resources/integration/integration.py � mpt_api_client/resources/integration/mixins/__init__.py � tests/unit/resources/integration/test_integration.py
f58b8f7 to
5744f2b
Compare
5744f2b to
76009ff
Compare
76009ff to
5be5e0c
Compare
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/unit/resources/integration/mixins/test_installation_mixin.py (1)
146-183: ⚡ Quick winAdd coverage for
token_for_account()withoutaccount_id.Current tests validate only the
account_id-provided branch. Adding the no-arg path would cover thequery_params=Nonebranch and guard endpoint behavior for default account-token retrieval.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/unit/resources/integration/mixins/test_installation_mixin.py` around lines 146 - 183, Add tests covering the no-argument branch of token_for_account: create both sync and async variants similar to test_token_for_account and test_async_token_for_account but call installation_service.token_for_account() and async_installation_service.token_for_account() with no arguments, set up respx.post for the same URL without the params argument (so query_params is None), mock the same httpx.Response payload, and assert mock_route.call_count == 1 and result.to_dict() equals the expected_response; this ensures the query_params=None branch is exercised.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/unit/resources/integration/mixins/test_installation_mixin.py`:
- Around line 146-183: Add tests covering the no-argument branch of
token_for_account: create both sync and async variants similar to
test_token_for_account and test_async_token_for_account but call
installation_service.token_for_account() and
async_installation_service.token_for_account() with no arguments, set up
respx.post for the same URL without the params argument (so query_params is
None), mock the same httpx.Response payload, and assert mock_route.call_count ==
1 and result.to_dict() equals the expected_response; this ensures the
query_params=None branch is exercised.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: c38a583e-85a1-4a99-b7da-c3478c68984d
📒 Files selected for processing (14)
e2e_config.test.jsonmpt_api_client/resources/integration/mixins/installation_mixin.pypyproject.tomltests/e2e/integration/conftest.pytests/e2e/integration/extensions/conftest.pytests/e2e/integration/extensions/test_async_extensions.pytests/e2e/integration/extensions/test_sync_extensions.pytests/e2e/integration/installations/__init__.pytests/e2e/integration/installations/conftest.pytests/e2e/integration/installations/helper.pytests/e2e/integration/installations/test_async_installations.pytests/e2e/integration/installations/test_sync_installations.pytests/unit/resources/integration/mixins/test_installation_mixin.pytests/unit/resources/integration/test_installations.py
💤 Files with no reviewable changes (2)
- tests/e2e/integration/extensions/test_async_extensions.py
- tests/e2e/integration/extensions/test_sync_extensions.py



Summary
Implements the
/public/v1/integration/installationsendpoint group as part of MPT-13310.Changes
mpt_api_client/resources/integration/installations.py—InstallationsService/AsyncInstallationsServicempt_api_client/resources/integration/mixins/installation_mixin.py— lifecycle actions: invite, install, uninstall, expireintegration.pyto exposeinstallationspropertytests/unit/resources/integration/test_installations.py+test_installation_mixin.pytests/e2e/integration/installations/Depends on
#277 (MPT-19892 — rename extensibility → integration)
Closes MPT-19908