-
Notifications
You must be signed in to change notification settings - Fork 1
π§ͺ Add integration tests for rule_based_extract #124
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -72,3 +72,36 @@ def test_file_path_extraction(self): | |||||||||||||||||||||||||||||||||||||||||||
| result = rule_based_extract("Edit the file src/main.py to fix the bug") | ||||||||||||||||||||||||||||||||||||||||||||
| entity_names = [e.name for e in result.entities] | ||||||||||||||||||||||||||||||||||||||||||||
| assert any("main.py" in n for n in entity_names) | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| def test_rule_based_extract_integration(self): | ||||||||||||||||||||||||||||||||||||||||||||
| text = "I prefer Python. The meeting is on 2025-10-12. Email me at test@example.com." | ||||||||||||||||||||||||||||||||||||||||||||
| result = rule_based_extract(text) | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| # Assert entities | ||||||||||||||||||||||||||||||||||||||||||||
| entity_names = [e.name for e in result.entities] | ||||||||||||||||||||||||||||||||||||||||||||
| assert "Python" in entity_names | ||||||||||||||||||||||||||||||||||||||||||||
| assert "test@example.com" in entity_names | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| # Assert preference relations | ||||||||||||||||||||||||||||||||||||||||||||
| prefers_rels = [r for r in result.relations if r.predicate == "prefers"] | ||||||||||||||||||||||||||||||||||||||||||||
| assert len(prefers_rels) > 0 | ||||||||||||||||||||||||||||||||||||||||||||
| assert prefers_rels[0].subject == "user" | ||||||||||||||||||||||||||||||||||||||||||||
| assert prefers_rels[0].object == "Python" | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| # Assert temporal_context | ||||||||||||||||||||||||||||||||||||||||||||
| assert "2025-10-12" in result.temporal_context | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| def test_rule_based_extract_dependency_relations(self): | ||||||||||||||||||||||||||||||||||||||||||||
| text = "Django depends on Python." | ||||||||||||||||||||||||||||||||||||||||||||
| result = rule_based_extract(text) | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| # Assert entities | ||||||||||||||||||||||||||||||||||||||||||||
| entity_names = [e.name for e in result.entities] | ||||||||||||||||||||||||||||||||||||||||||||
| assert "Django" in entity_names | ||||||||||||||||||||||||||||||||||||||||||||
| assert "Python" in entity_names | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| # Assert dependency relations | ||||||||||||||||||||||||||||||||||||||||||||
| depends_rels = [r for r in result.relations if r.predicate == "depends_on"] | ||||||||||||||||||||||||||||||||||||||||||||
| assert len(depends_rels) > 0 | ||||||||||||||||||||||||||||||||||||||||||||
| assert depends_rels[0].subject == "Django" | ||||||||||||||||||||||||||||||||||||||||||||
| assert depends_rels[0].object == "Python" | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+98
to
+107
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the previous test, verifying the
Suggested change
References
|
||||||||||||||||||||||||||||||||||||||||||||
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.
The assertions in this integration test can be made more robust and precise. Verifying the
entity_typeensures that the rule-based logic is correctly categorizing entities (e.g., 'tech' vs 'person'), which is critical for downstream memory processing. Additionally, using exact equality for the relation count and temporal context provides better protection against regressions or unexpected side effects in the extraction pipeline, adhering to the SOTA+ 'Production-Grade' philosophy.References