Skip to content

Conversation

ialarmedalien
Copy link
Collaborator

@ialarmedalien ialarmedalien commented Sep 26, 2025

Just as it says in the title -- splitting out long SchemaView tests by the functions that they are testing.

See inline comments for details.

@ialarmedalien ialarmedalien self-assigned this Sep 26, 2025
@ialarmedalien ialarmedalien added enhancement New feature or request testing labels Sep 26, 2025
Copy link

codecov bot commented Sep 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.36%. Comparing base (804c65b) to head (2b81341).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #456      +/-   ##
==========================================
- Coverage   77.47%   77.36%   -0.12%     
==========================================
  Files          52       52              
  Lines        4470     4470              
  Branches      975      975              
==========================================
- Hits         3463     3458       -5     
- Misses        782      785       +3     
- Partials      225      227       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ialarmedalien ialarmedalien changed the title Split out long test method into many tests SchemaView tests: split out long test method into many tests Sep 26, 2025
@ialarmedalien ialarmedalien changed the title SchemaView tests: split out long test method into many tests test_schemaview.py: split out long test method into many tests Sep 26, 2025
assert view.permissible_value_parent(pv, e.name) == ["LION"]
assert view.permissible_value_ancestors(pv, e.name) == ["ANGRY_LION", "LION", "CAT"]
assert view.permissible_value_descendants(pv, e.name) == ["ANGRY_LION"]
animals = "Animals"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made these tests more comprehensive and got rid of the unnecessary iteration / nesting

assert set(e.include[0].reachable_from.source_nodes) == {"GO:0007049", "GO:0022403"}


def test_schemaview(schema_view_no_imports: SchemaView) -> None:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is far too long and tests too many different things. It is better to keep tests short and focused on specific, related methods. I went through the method and split it up as logically as I could.

Comment on lines -1068 to -1497
logger.debug(view.imports_closure())
assert len(view.imports_closure()) == 1
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previous PR has a better test of the imports closure

Comment on lines -1071 to -1500
all_cls = view.all_classes()
logger.debug(f"n_cls = {len(all_cls)}")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

least favourite test anti-pattern: printing out stuff and not doing any testing on it.

with pytest.raises(ValueError, match='property to introspect must be of type "boolean"'):
view.slot_is_true_for_metadata_property("aliases", "aliases")

for tn, t in view.all_types().items():
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested more thoroughly elsewhere - e.g. see the creature schema tests

Comment on lines -1123 to -1552
for sn, s in view.all_slots().items():
logger.info(f"SN = {sn} RANGE={s.range}")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, tested better elsewhere


assert view.get_uri(COMPANY) == "ks:Company"

# test induced slots
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move all these induced slot tests down to their own induced slot section

assert view.class_slots(PERSON) == view.class_slots(ADULT)
assert set(view.class_slots(COMPANY)) == {"id", "name", "ceo", "aliases"}

assert view.get_class(AGENT).class_uri == "prov:Agent"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already have these tests for get_uri and class_uri in another method - no need to repeat them here.

@ialarmedalien ialarmedalien changed the base branch from schemaview_explode_tests to main October 2, 2025 14:37
@ialarmedalien ialarmedalien force-pushed the schemaview_explode_tests_II branch from 5ba5735 to 2b81341 Compare October 4, 2025 17:03
@ialarmedalien ialarmedalien merged commit 1b67264 into main Oct 4, 2025
17 checks passed
@ialarmedalien ialarmedalien deleted the schemaview_explode_tests_II branch October 4, 2025 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants