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.37%. Comparing base (52f37ac) to head (dedc496).

Additional details and impacted files
@@                    Coverage Diff                    @@
##           schemaview_explode_tests     #456   +/-   ##
=========================================================
  Coverage                     77.37%   77.37%           
=========================================================
  Files                            52       52           
  Lines                          4478     4478           
  Branches                        979      979           
=========================================================
  Hits                           3465     3465           
  Misses                          785      785           
  Partials                        228      228           

☔ 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 -1069
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 -1072
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 -1124
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.

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.

1 participant