Test: Guard Fill invocation contract in main orchestration#227
Test: Guard Fill invocation contract in main orchestration#227Aryama-srivastav wants to merge 1 commit intofireform-core:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a regression test to prevent reintroducing a Fill constructor vs fill_form invocation mismatch in the PDF fill orchestration (by statically checking src/main.py’s call pattern).
Changes:
- Added a new pytest test that reads
src/main.pyand asserts it usesFill.fill_form(...). - Added a negative assertion to prevent the known-bad pattern
Fill(user_input=user_input).fill_form(...).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| main_path = Path(__file__).resolve().parents[1] / "main.py" | ||
| content = main_path.read_text(encoding="utf-8") | ||
|
|
||
| assert "Fill.fill_form(" in content | ||
| assert "Fill(user_input=user_input).fill_form(" not in content |
There was a problem hiding this comment.
This test is brittle because it relies on raw substring matches in main.py. It can produce false positives (e.g., Fill.fill_form( appears in a comment/string) and false negatives (valid calls formatted as Fill.fill_form ( with whitespace/newlines). Consider parsing main.py with ast and asserting there is a Call to attribute Fill.fill_form, and that there is no Call where Fill(...) is invoked and then .fill_form is called.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
Summary
Adds a regression test to prevent reintroducing the
Fillinvocation mismatch in the PDF fill orchestration flow. Fix #226This issue can cause runtime failure if
src/main.pycalls:Fill(user_input=user_input).fill_form(...)
What Changed
Why
The constructor/signature mismatch is a high-impact reliability risk that can crash the main report generation path with TypeError.
Even though the current code is already correct, this test ensures the bug does not regress in future edits.
Validation
Ran:
-m pytest test_main_invocation.py -q
Result:
1 passed
Scope
Test-only change
No runtime behavior changes