Skip to content

MPT-20429: Added endpoints and e2e tests for spotlight objects#315

Merged
d3rky merged 1 commit intomainfrom
MPT-20429-add-endpoints-and-e-2-e-tests-for-spotlight-objects
Apr 21, 2026
Merged

MPT-20429: Added endpoints and e2e tests for spotlight objects#315
d3rky merged 1 commit intomainfrom
MPT-20429-add-endpoints-and-e-2-e-tests-for-spotlight-objects

Conversation

@robcsegal
Copy link
Copy Markdown
Contributor

@robcsegal robcsegal commented Apr 20, 2026

This pull request introduces the new Spotlight API module to the client, providing both synchronous and asynchronous support for spotlight object resources. It includes full implementation of the resource, integration into the main API client, and comprehensive unit and end-to-end tests.

Spotlight API Module Implementation:

  • Added new Spotlight and AsyncSpotlight classes in mpt_api_client/resources/spotlight/spotlight.py, exposing the objects property for managing spotlight objects.
  • Implemented SpotlightObject model, SpotlightObjectsService, and AsyncSpotlightObjectsService in mpt_api_client/resources/spotlight/objects.py, including refresh methods for both sync and async usage.

Integration with Main Client and Exports:

  • Registered Spotlight and AsyncSpotlight in the main MPTClient and AsyncMPTClient classes in mpt_api_client/mpt_client.py, and updated exports in mpt_api_client/resources/__init__.py and mpt_api_client/resources/spotlight/__init__.py. [1] [2] [3] [4] [5] [6] [7] [8]

Testing:

  • Added unit tests for the Spotlight and AsyncSpotlight modules and their service properties in tests/unit/resources/spotlight/test_spotlight.py, and for the SpotlightObjectsService and AsyncSpotlightObjectsService (including the refresh method and mixin presence) in tests/unit/resources/spotlight/test_objects.py. [1] [2]
  • Added end-to-end tests for both sync and async spotlight object operations in tests/e2e/spotlight/test_sync_spotlight.py and tests/e2e/spotlight/test_async_spotlight.py. [1] [2]
  • Updated tests/unit/test_mpt_client.py to include Spotlight and AsyncSpotlight in client resource tests. [1] [2] [3] [4]

Closes MPT-20429

Release Notes

  • Added Spotlight API module with synchronous and asynchronous clients: Spotlight and AsyncSpotlight
  • Implemented SpotlightObject model and services: SpotlightObjectsService and AsyncSpotlightObjectsService
  • Added refresh() to sync and async services to refresh all objects or specific objects by ID (object_id, default "-")
  • Integrated spotlight property into MPTClient and AsyncMPTClient
  • Exported Spotlight and AsyncSpotlight in package public APIs
  • Added unit tests for Spotlight wrappers, services, mixin presence, and refresh request routing
  • Added end-to-end tests (sync and async) covering selection and refresh operations
  • Updated client resource tests to include the new Spotlight resource

@robcsegal robcsegal requested a review from a team as a code owner April 20, 2026 20:09
@robcsegal robcsegal requested review from alephsur and d3rky April 20, 2026 20:09
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 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: cf1f8314-6139-4cd1-9253-09ae75ab3c95

📥 Commits

Reviewing files that changed from the base of the PR and between 8e3055b and 11e2b75.

📒 Files selected for processing (10)
  • mpt_api_client/mpt_client.py
  • mpt_api_client/resources/__init__.py
  • mpt_api_client/resources/spotlight/__init__.py
  • mpt_api_client/resources/spotlight/objects.py
  • mpt_api_client/resources/spotlight/spotlight.py
  • tests/e2e/spotlight/test_async_spotlight.py
  • tests/e2e/spotlight/test_sync_spotlight.py
  • tests/unit/resources/spotlight/test_objects.py
  • tests/unit/resources/spotlight/test_spotlight.py
  • tests/unit/test_mpt_client.py
✅ Files skipped from review due to trivial changes (3)
  • tests/unit/resources/spotlight/test_spotlight.py
  • tests/e2e/spotlight/test_sync_spotlight.py
  • tests/unit/resources/spotlight/test_objects.py
🚧 Files skipped from review as they are similar to previous changes (5)
  • mpt_api_client/resources/init.py
  • tests/unit/test_mpt_client.py
  • mpt_api_client/mpt_client.py
  • mpt_api_client/resources/spotlight/objects.py
  • tests/e2e/spotlight/test_async_spotlight.py

📝 Walkthrough

Walkthrough

Added a new spotlight resource with sync/async wrappers exposing an objects service; introduced SpotlightObject model and sync/async objects services supporting get, iterate, and refresh; added unit and e2e tests for construction, property access, and refresh routing.

Changes

Cohort / File(s) Summary
Client exposure
mpt_api_client/mpt_client.py, mpt_api_client/resources/__init__.py
Added spotlight properties to MPTClient and AsyncMPTClient returning Spotlight/AsyncSpotlight; exported Spotlight and AsyncSpotlight from resources package.
Spotlight package
mpt_api_client/resources/spotlight/__init__.py, mpt_api_client/resources/spotlight/spotlight.py
Added spotlight package and wrapper classes Spotlight and AsyncSpotlight that store the HTTP client and expose an objects property.
Spotlight objects service
mpt_api_client/resources/spotlight/objects.py
Added SpotlightObject model, SpotlightObjectsService and AsyncSpotlightObjectsService, config with endpoint /public/v1/spotlight/objects, and refresh(object_id: str = "-")/async refresh(...) performing POST to .../{id}/refresh.
Unit tests
tests/unit/resources/spotlight/test_objects.py, tests/unit/resources/spotlight/test_spotlight.py, tests/unit/test_mpt_client.py
Added tests verifying service mixins, refresh request routing (sync/async), wrapper initialization, .objects property behavior, and client-level spotlight exposure.
End-to-end tests
tests/e2e/spotlight/test_async_spotlight.py, tests/e2e/spotlight/test_sync_spotlight.py
Added flaky e2e tests that select spotlight objects and exercise refresh for all and specific objects in async and sync contexts.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 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 in the required MPT-XXXX format: MPT-20429.
Test Coverage Required ✅ Passed The PR modifies code files in the spotlight resource module while including comprehensive test coverage with 5 test files.
Single Commit Required ✅ Passed The PR contains exactly one commit (11e2b75 Added endpoints and e2e tests for spotlight objects), confirmed by git log and branch comparison.

✏️ 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.

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: 2

🤖 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/spotlight/test_async_spotlight.py`:
- Around line 28-33: The test test_refresh_spotlight_objects_specific assumes
spotlight_objects_data has elements and directly indexes
spotlight_objects_data[0]; add a guard to handle empty fixture data by checking
spotlight_objects_data before indexing (e.g., if not spotlight_objects_data:
pytest.skip("no spotlight objects seeded") or assert spotlight_objects_data,
"expected seeded spotlight objects"), then proceed to call
spotlight_objects_service.refresh(object_id=result.id) using the safely obtained
result; update references to spotlight_objects_data and
spotlight_objects_service.refresh in the test accordingly.

In `@tests/e2e/spotlight/test_sync_spotlight.py`:
- Around line 28-31: The test test_refresh_spotlight_objects_specific can raise
IndexError when spotlight_objects_data is empty; add a guard at the start to
check if spotlight_objects_data is empty and either call pytest.skip("no
spotlight seed data") or assert spotlight_objects_data, then proceed to fetch
result = spotlight_objects_data[0] and call
spotlight_objects_service.refresh(object_id=result.id). This uses the existing
symbols spotlight_objects_data and spotlight_objects_service.refresh to locate
where to insert the check.
🪄 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: c92904c6-fa37-44d6-9be6-909961ce6607

📥 Commits

Reviewing files that changed from the base of the PR and between 3acc285 and f438386.

📒 Files selected for processing (10)
  • mpt_api_client/mpt_client.py
  • mpt_api_client/resources/__init__.py
  • mpt_api_client/resources/spotlight/__init__.py
  • mpt_api_client/resources/spotlight/objects.py
  • mpt_api_client/resources/spotlight/spotlight.py
  • tests/e2e/spotlight/test_async_spotlight.py
  • tests/e2e/spotlight/test_sync_spotlight.py
  • tests/unit/resources/spotlight/test_objects.py
  • tests/unit/resources/spotlight/test_spotlight.py
  • tests/unit/test_mpt_client.py

Comment thread tests/e2e/spotlight/test_async_spotlight.py Outdated
Comment thread tests/e2e/spotlight/test_sync_spotlight.py Outdated
@robcsegal robcsegal force-pushed the MPT-20429-add-endpoints-and-e-2-e-tests-for-spotlight-objects branch from f438386 to 8e3055b Compare April 20, 2026 20:20
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)
mpt_api_client/resources/spotlight/spotlight.py (1)

14-17: Consider caching service instances in properties.

The objects property creates a new service instance on every access, which may be inefficient if accessed multiple times. However, this pattern is consistent with other resource properties in the codebase (e.g., program, spotlight in MPTClient).

If service instances are lightweight and stateless, the current approach is fine. Otherwise, consider caching:

`@property`
def objects(self) -> SpotlightObjectsService:
    """Spotlight Objects service."""
    if not hasattr(self, '_objects'):
        self._objects = SpotlightObjectsService(http_client=self.http_client)
    return self._objects

Also applies to: 26-29

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@mpt_api_client/resources/spotlight/spotlight.py` around lines 14 - 17, The
objects property currently instantiates a new SpotlightObjectsService on each
access (method objects) — change it to cache the instance on the Spotlight class
(e.g., store in self._objects) so subsequent accesses return the same
SpotlightObjectsService(http_client=self.http_client) instance; apply the same
caching pattern to the other similar properties referenced (the ones creating
SpotlightProgramsService/SpotlightService or similar) to avoid repeated
construction while preserving the existing type hints and docstrings.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@mpt_api_client/resources/spotlight/spotlight.py`:
- Around line 14-17: The objects property currently instantiates a new
SpotlightObjectsService on each access (method objects) — change it to cache the
instance on the Spotlight class (e.g., store in self._objects) so subsequent
accesses return the same SpotlightObjectsService(http_client=self.http_client)
instance; apply the same caching pattern to the other similar properties
referenced (the ones creating SpotlightProgramsService/SpotlightService or
similar) to avoid repeated construction while preserving the existing type hints
and docstrings.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: fbd0d1fb-d6d4-41a4-92b7-d654322e7be9

📥 Commits

Reviewing files that changed from the base of the PR and between f438386 and 8e3055b.

📒 Files selected for processing (10)
  • mpt_api_client/mpt_client.py
  • mpt_api_client/resources/__init__.py
  • mpt_api_client/resources/spotlight/__init__.py
  • mpt_api_client/resources/spotlight/objects.py
  • mpt_api_client/resources/spotlight/spotlight.py
  • tests/e2e/spotlight/test_async_spotlight.py
  • tests/e2e/spotlight/test_sync_spotlight.py
  • tests/unit/resources/spotlight/test_objects.py
  • tests/unit/resources/spotlight/test_spotlight.py
  • tests/unit/test_mpt_client.py
✅ Files skipped from review due to trivial changes (4)
  • tests/unit/test_mpt_client.py
  • mpt_api_client/mpt_client.py
  • tests/unit/resources/spotlight/test_spotlight.py
  • mpt_api_client/resources/init.py
🚧 Files skipped from review as they are similar to previous changes (4)
  • tests/unit/resources/spotlight/test_objects.py
  • tests/e2e/spotlight/test_sync_spotlight.py
  • mpt_api_client/resources/spotlight/objects.py
  • tests/e2e/spotlight/test_async_spotlight.py

@robcsegal robcsegal changed the title MPT-13313: Added endpoints and e2e tests for spotlight objects MPT-20429: Added endpoints and e2e tests for spotlight objects Apr 20, 2026
@robcsegal robcsegal force-pushed the MPT-20429-add-endpoints-and-e-2-e-tests-for-spotlight-objects branch from 8e3055b to 11e2b75 Compare April 20, 2026 21:23
@sonarqubecloud
Copy link
Copy Markdown

@d3rky d3rky merged commit dbf9103 into main Apr 21, 2026
4 checks passed
@d3rky d3rky deleted the MPT-20429-add-endpoints-and-e-2-e-tests-for-spotlight-objects branch April 21, 2026 08:29
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