-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor ingestion helpers and expand tests #9
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This PR refactors the ingestion module into reusable helper functions with improved validation and error handling. It replaces the previous command-line based approach with structured payload parsing and adds comprehensive test coverage.
- Refactored
add_documents.pyinto modular helper functions with type hints and proper validation - Expanded BDD tests to cover negative scenarios and structured payloads using Behave tables
- Added comprehensive pytest unit tests for payload parsing and ingestion logic
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| add_documents.py | Complete refactor from command-line script to modular helpers with validation and error handling |
| bdd_tests.feature | Added structured test scenarios with tables and negative test cases |
| add_documents_bdd_tests.py | Updated Behave steps to use new helper functions and handle structured data |
| tests/test_add_documents.py | New pytest unit tests covering payload parsing and ingestion validation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| def load_openai_key() -> str: | ||
| """Load the OpenAI API key from the environment.""" | ||
|
|
||
| from dotenv import load_dotenv |
Copilot
AI
Oct 7, 2025
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.
[nitpick] The import is placed inside the function, but it's used in multiple functions. Consider moving this to the top-level imports for consistency and performance.
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.
@codex fix comments
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.
Summary
- Resolved the optional
python-dotenvdependency at module import time and added a clear fallback error when it is unavailable. add_documents.pyL5-L33 - Updated the pytest suite to load
add_documentsviaimportlibrather than mutatingsys.path. tests/test_add_documents.pyL1-L21
Testing
- ✅
pytest
Co-authored-by: Copilot <[email protected]>
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_68e42c0f3c5c83288826a82290ba83c0