-
Notifications
You must be signed in to change notification settings - Fork 1
π§ͺ Add integration test for rule_based_extract pipeline #113
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,29 @@ 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_complete_pipeline(self): | ||||||||||||||||||||||||||||||||||||||||||||
| """Test rule_based_extract with a complete input that tests all extraction parts.""" | ||||||||||||||||||||||||||||||||||||||||||||
| text = "I prefer Python. Python requires Docker. I built this on 2024-01-01." | ||||||||||||||||||||||||||||||||||||||||||||
| result = rule_based_extract(text) | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| assert isinstance(result, ExtractionResult) | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| # Test Entities | ||||||||||||||||||||||||||||||||||||||||||||
| entity_names = [e.name for e in result.entities] | ||||||||||||||||||||||||||||||||||||||||||||
| assert "Python" in entity_names | ||||||||||||||||||||||||||||||||||||||||||||
| assert "Docker" in entity_names | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| # Test Relations | ||||||||||||||||||||||||||||||||||||||||||||
| assert len(result.relations) == 2 | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| pref_relation = next(r for r in result.relations if r.predicate == "prefers") | ||||||||||||||||||||||||||||||||||||||||||||
| assert pref_relation.subject == "user" | ||||||||||||||||||||||||||||||||||||||||||||
| assert pref_relation.object == "Python" | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| dep_relation = next(r for r in result.relations if r.predicate == "depends_on") | ||||||||||||||||||||||||||||||||||||||||||||
| assert dep_relation.subject == "Python" | ||||||||||||||||||||||||||||||||||||||||||||
| assert dep_relation.object == "Docker" | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+89
to
+97
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. Using
Suggested change
References
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| # Test Temporal Context | ||||||||||||||||||||||||||||||||||||||||||||
| assert result.temporal_context == "2024-01-01" | ||||||||||||||||||||||||||||||||||||||||||||
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 current entity assertions only verify the presence of names but do not check the
entity_typeor ensure that no unexpected entities were extracted. For a robust integration test, it is better to verify the exact count and the attributes of the extracted entities.References