-
Notifications
You must be signed in to change notification settings - Fork 50
LCORE-628: OpenAPI integration tests #743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LCORE-628: OpenAPI integration tests #743
Conversation
WalkthroughThis patch introduces a new YAML test configuration file for Lightspeed Core Service and expands OpenAPI integration tests to validate API specifications loaded from both files and HTTP URLs, with new test fixtures and comprehensive endpoint validation. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
c05cc8e to
3768324
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/integration/test_openapi_json.py (1)
178-231: Consolidate shared endpoint data.Both parametrized tests repeat the same
(path, method, expected_codes)tuples; extracting them into a shared constant (or helper generator) would keep the assertions in sync and reduce maintenance churn.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
tests/configuration/lightspeed-stack-proper-name.yaml(1 hunks)tests/integration/test_openapi_json.py(4 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.py: All modules start with descriptive module-level docstrings explaining purpose
Use logger = logging.getLogger(name) for module logging after import logging
Define type aliases at module level for clarity
All functions require docstrings with brief descriptions
Provide complete type annotations for all function parameters and return types
Use typing_extensions.Self in model validators where appropriate
Use modern union syntax (str | int) and Optional[T] or T | None consistently
Function names use snake_case with descriptive, action-oriented prefixes (get_, validate_, check_)
Avoid in-place parameter modification; return new data structures instead of mutating arguments
Use appropriate logging levels: debug, info, warning, error with clear messages
All classes require descriptive docstrings explaining purpose
Class names use PascalCase with conventional suffixes (Configuration, Error/Exception, Resolver, Interface)
Abstract base classes should use abc.ABC and @AbstractMethod for interfaces
Provide complete type annotations for all class attributes
Follow Google Python docstring style for modules, classes, and functions, including Args, Returns, Raises, Attributes sections as needed
Files:
tests/integration/test_openapi_json.py
tests/{unit,integration}/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
tests/{unit,integration}/**/*.py: Use pytest for all unit and integration tests
Do not use unittest in tests; pytest is the standard
Files:
tests/integration/test_openapi_json.py
tests/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
tests/**/*.py: Use pytest-mock to create AsyncMock objects for async interactions in tests
Use the shared auth mock constant: MOCK_AUTH = ("mock_user_id", "mock_username", False, "mock_token") in tests
Files:
tests/integration/test_openapi_json.py
🧠 Learnings (1)
📓 Common learnings
Learnt from: radofuchs
Repo: lightspeed-core/lightspeed-stack PR: 485
File: tests/e2e/features/environment.py:87-95
Timestamp: 2025-09-02T11:09:40.404Z
Learning: In the lightspeed-stack e2e tests, noop authentication tests use the default lightspeed-stack.yaml configuration, while noop-with-token tests use the Authorized tag to trigger a config swap to the specialized noop-with-token configuration file.
🧬 Code graph analysis (1)
tests/integration/test_openapi_json.py (1)
src/configuration.py (2)
configuration(73-77)load_configuration(56-62)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: build-pr
- GitHub Check: e2e_tests (azure)
- GitHub Check: e2e_tests (ci)
| configuration_filename = "tests/configuration/lightspeed-stack-proper-name.yaml" | ||
| cfg = configuration | ||
| cfg.load_configuration(configuration_filename) | ||
| from app.main import app # pylint: disable=C0415 | ||
|
|
||
| client = TestClient(app) | ||
| response = client.get("/openapi.json") | ||
| assert response.status_code == requests.codes.ok # pylint: disable=no-member | ||
|
|
||
| # this line ensures that response payload contains proper JSON | ||
| payload = response.json() | ||
| assert payload is not None, "Incorrect response" | ||
|
|
||
| return payload | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restore configuration after overriding.
configuration.load_configuration(...) mutates the shared singleton for the whole process. Because we never reload the previous/default file, every later test in the same session inherits lightspeed-stack-proper-name.yaml, breaking isolation for suites that expect the stock stack config (notably the Authorized/Noop swaps noted in our e2e learnings). Please scope this override and restore the prior configuration once the OpenAPI payload is fetched (e.g., capture the active config, yield the TestClient, then reload the original file in finally). Based on learnings
🤖 Prompt for AI Agents
In tests/integration/test_openapi_json.py around lines 37 to 52, the call to
configuration.load_configuration(...) mutates the shared singleton and is not
restored; capture the current active configuration (e.g., save the currently
loaded configuration filename or serialized config state) before calling
load_configuration, perform the TestClient request, and then in a finally block
(or using yield in a fixture) reload the saved configuration to restore the
prior state so other tests aren't affected.
Description
LCORE-628: OpenAPI integration tests
Type of change
Related Tickets & Documents
Summary by CodeRabbit