Skip to content

MPT-20430: add endpoints and e2e tests for spotlight queries#321

Merged
d3rky merged 1 commit intomainfrom
MPT-20430-add-endpoints-and-e-2-e-tests-for-spotlight-queries
Apr 24, 2026
Merged

MPT-20430: add endpoints and e2e tests for spotlight queries#321
d3rky merged 1 commit intomainfrom
MPT-20430-add-endpoints-and-e-2-e-tests-for-spotlight-queries

Conversation

@robcsegal
Copy link
Copy Markdown
Contributor

@robcsegal robcsegal commented Apr 23, 2026

🤖 AI-generated PR — Please review carefully.

What changed

  • Added mpt_api_client/resources/spotlight/queries.py with a dedicated queries resource module covering sync and async endpoint operations.
  • Extended mpt_api_client/resources/spotlight/spotlight.py to expose the new queries resource.
  • Added e2e tests for query endpoints under tests/e2e/spotlight/query/ (sync and async).
  • Renamed test_async_spotlight.pytest_async_object.py and test_sync_spotlight.pytest_sync_object.py for naming consistency with the object-level scope.
  • Added unit tests for the new queries resource in tests/unit/resources/spotlight/test_queries.py.
  • Updated existing spotlight unit tests in tests/unit/resources/spotlight/test_spotlight.py to cover the new surface.
  • Updated e2e_config.test.json with required query test configuration.

Closes MPT-20430

  • Added SpotlightQuery model and query service classes (SpotlightQueriesService and AsyncSpotlightQueriesService) for the /public/v1/spotlight/queries endpoint with support for get-by-id and collection retrieval operations
  • Exposed the new queries service from the Spotlight and AsyncSpotlight modules via .queries properties
  • Added end-to-end tests for synchronous and asynchronous query operations, including scenarios for retrieving queries by ID, handling invalid IDs, listing all queries, and filtering with RQL
  • Added unit tests for the new queries resource validating mixin implementations and model field mapping
  • Updated existing spotlight unit tests to exercise the new queries surface
  • Updated e2e_config.test.json with spotlight query ID configuration

AI Generated.
Add a dedicated queries module for spotlight with full sync and async endpoint coverage. Rename existing spotlight e2e test files from test_*_spotlight to test_*_object for consistency, and add query-specific e2e tests under tests/e2e/spotlight/query/. Update unit tests to cover the new queries resource and extend the existing spotlight unit suite.
@robcsegal robcsegal requested a review from a team as a code owner April 23, 2026 15:17
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

📝 Walkthrough

Walkthrough

This pull request introduces a new Spotlight "queries" resource layer to the MPT API Python client. It adds a SpotlightQuery model with synchronous and asynchronous service classes wired to the /public/v1/spotlight/queries endpoint, integrates the new queries service into the Spotlight module, updates the e2e configuration with a query ID, and provides comprehensive unit and e2e test coverage.

Changes

Cohort / File(s) Summary
Configuration
e2e_config.test.json
Adds spotlight.query.id identifier entry and updates JSON formatting with trailing comma.
Service Implementation
mpt_api_client/resources/spotlight/queries.py
Defines SpotlightQuery model and sync/async service classes (SpotlightQueriesService, AsyncSpotlightQueriesService) with get-by-id and collection retrieval mixins targeting /public/v1/spotlight/queries endpoint.
Module Integration
mpt_api_client/resources/spotlight/spotlight.py
Exposes .queries property accessors on both Spotlight and AsyncSpotlight classes to instantiate corresponding query services.
E2E Test Fixtures
tests/e2e/spotlight/query/conftest.py
Introduces pytest fixtures for configured spotlight query ID and invalid query ID placeholder for test scenarios.
E2E Tests
tests/e2e/spotlight/query/test_sync_query.py, tests/e2e/spotlight/query/test_async_query.py
Implements four test scenarios each for sync and async operations: get by valid ID, error handling for invalid ID, paginated listing, and RQL-filtered queries with field selection.
Unit Tests
tests/unit/resources/spotlight/test_queries.py, tests/unit/resources/spotlight/test_spotlight.py
Validates service instantiation, mixin implementation, model field mapping, and property exposure on Spotlight/AsyncSpotlight classes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PR #315: Extends Spotlight resource by adding subresource service properties to the same Spotlight/AsyncSpotlight classes, following the same integration pattern as this PR's .queries property addition.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Jira Issue Key In Title ✅ Passed PR title contains exactly one Jira issue key in the required format (MPT-XXXX): MPT-20430.
Test Coverage Required ✅ Passed PR modifies 2 code files in mpt_api_client/resources/spotlight/ with comprehensive test coverage including 5 test files covering unit and end-to-end tests.
Single Commit Required ✅ Passed The pull request contains exactly one commit (ed9d7f8), satisfying the requirement for a clean git history.

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

@robcsegal robcsegal changed the title MPT-20430 add endpoints and e2e tests for spotlight queries MPT-20430: add endpoints and e2e tests for spotlight queries Apr 23, 2026
@sonarqubecloud
Copy link
Copy Markdown

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 (2)
tests/e2e/spotlight/query/test_sync_query.py (1)

34-36: Strengthen filter test by asserting the returned query ID.

At Line 36, asserting only len(result) == 1 is weak; add an identity assertion to verify the filter actually matched the requested query.

Suggested improvement
     result = list(filtered_spotlight_queries.iterate())
 
     assert len(result) == 1
+    assert result[0].id == spotlight_query_id
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/spotlight/query/test_sync_query.py` around lines 34 - 36, The test
currently only checks the count of results from
filtered_spotlight_queries.iterate(); strengthen it by also asserting the
identity of the returned query: after collecting result =
list(filtered_spotlight_queries.iterate()), add an assertion that the single
returned item's id equals the expected query id (e.g. assert result[0].id ==
expected_query.id or assert result[0]["id"] == expected_query_id depending on
how query objects are represented) to ensure the filter matched the intended
query.
tests/e2e/spotlight/query/test_async_query.py (1)

34-36: Add ID assertion to harden async filter validation.

At Line 36, len(result) == 1 does not prove the filter matched the expected query; assert the returned ID as well.

Suggested improvement
     result = [query async for query in filtered_spotlight_queries.iterate()]
 
     assert len(result) == 1
+    assert result[0].id == spotlight_query_id
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/spotlight/query/test_async_query.py` around lines 34 - 36, The test
currently only checks len(result) == 1 after calling
filtered_spotlight_queries.iterate(), but doesn't verify the matched record;
update the assertion to also check the returned query's ID (e.g., assert
result[0].id == expected_query.id or assert result[0]["id"] == expected_id) so
the async filter actually returned the expected query; use the same expected
identifier set up earlier in the test (expected_query or expected_id) and
reference result[0] from the list produced by
filtered_spotlight_queries.iterate().
🤖 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/spotlight/query/test_async_query.py`:
- Around line 34-36: The test currently only checks len(result) == 1 after
calling filtered_spotlight_queries.iterate(), but doesn't verify the matched
record; update the assertion to also check the returned query's ID (e.g., assert
result[0].id == expected_query.id or assert result[0]["id"] == expected_id) so
the async filter actually returned the expected query; use the same expected
identifier set up earlier in the test (expected_query or expected_id) and
reference result[0] from the list produced by
filtered_spotlight_queries.iterate().

In `@tests/e2e/spotlight/query/test_sync_query.py`:
- Around line 34-36: The test currently only checks the count of results from
filtered_spotlight_queries.iterate(); strengthen it by also asserting the
identity of the returned query: after collecting result =
list(filtered_spotlight_queries.iterate()), add an assertion that the single
returned item's id equals the expected query id (e.g. assert result[0].id ==
expected_query.id or assert result[0]["id"] == expected_query_id depending on
how query objects are represented) to ensure the filter matched the intended
query.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: d063f1fb-25be-40cc-a9d9-769fc1d5508e

📥 Commits

Reviewing files that changed from the base of the PR and between 5c70074 and ed9d7f8.

📒 Files selected for processing (10)
  • e2e_config.test.json
  • mpt_api_client/resources/spotlight/queries.py
  • mpt_api_client/resources/spotlight/spotlight.py
  • tests/e2e/spotlight/query/conftest.py
  • tests/e2e/spotlight/query/test_async_query.py
  • tests/e2e/spotlight/query/test_sync_query.py
  • tests/e2e/spotlight/test_async_object.py
  • tests/e2e/spotlight/test_sync_object.py
  • tests/unit/resources/spotlight/test_queries.py
  • tests/unit/resources/spotlight/test_spotlight.py

@d3rky d3rky merged commit 4f6bdeb into main Apr 24, 2026
4 checks passed
@d3rky d3rky deleted the MPT-20430-add-endpoints-and-e-2-e-tests-for-spotlight-queries branch April 24, 2026 07:14
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