MPT-19908: add /integration/installations service#281
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds an installations integration resource: Installation model, redeem mixins, InstallationsService/AsyncInstallationsService, Integration property wiring, unit and E2E tests, e2e fixtures/helpers, config entries, and a Flake8 per-file-ignore. 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
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
5be5e0c to
282c397
Compare
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/e2e/integration/installations/test_async_installations.py (1)
35-35: 💤 Low valueConsider simplifying the condition check.
Line 35 uses
if not ... ==instead of the more idiomatic!=. While functionally equivalent, the latter is clearer.♻️ Optional simplification
- if not invitation_payload.get("installationId") == async_created_installation_invite.id: + if invitation_payload.get("installationId") != async_created_installation_invite.id:🤖 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/e2e/integration/installations/test_async_installations.py` at line 35, Replace the awkward equality-negation pattern by using the idiomatic inequality operator: change the conditional that checks invitation_payload.get("installationId") against async_created_installation_invite.id from "if not ... == ..." to "if ... != ..."; update the condition in the test (the line referencing invitation_payload.get("installationId") and async_created_installation_invite.id) accordingly so the logic remains identical but reads more clearly.
🤖 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/e2e/integration/installations/test_async_installations.py`:
- Line 35: Replace the awkward equality-negation pattern by using the idiomatic
inequality operator: change the conditional that checks
invitation_payload.get("installationId") against
async_created_installation_invite.id from "if not ... == ..." to "if ... !=
..."; update the condition in the test (the line referencing
invitation_payload.get("installationId") and
async_created_installation_invite.id) accordingly so the logic remains identical
but reads more clearly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 9735441c-b072-4865-b7b3-3fcd080c699c
📒 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_sync_extensions.py
- tests/e2e/integration/extensions/test_async_extensions.py
✅ Files skipped from review due to trivial changes (5)
- tests/e2e/integration/conftest.py
- pyproject.toml
- tests/e2e/integration/extensions/conftest.py
- e2e_config.test.json
- tests/unit/resources/integration/mixins/test_installation_mixin.py
🚧 Files skipped from review as they are similar to previous changes (1)
- mpt_api_client/resources/integration/mixins/installation_mixin.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