Skip to content

Commit

Permalink
Improve error message on missing root links
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-eq committed Jan 3, 2024
1 parent c33a64e commit 9a0d0d3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
7 changes: 4 additions & 3 deletions komodo/symlink/sanity_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ def assert_root_nodes(link_dict):
inferred_roots = _get_root_nodes(link_dict)
if set(input_roots) != inferred_roots:
raise AssertionError(
"The roots in the link-tree is not matching "
+ "the roots defined in link_roots in dict\n"
"The roots in the link-tree do not match "
+ "the roots defined in the root_links dict\n"
+ f"Roots defined: {set(input_roots)}\n"
+ f"Roots expected: {inferred_roots}",
+ f"Roots expected: {inferred_roots}\n"
+ f"Missing root(s): {str(set(inferred_roots).difference(input_roots))}"
)


Expand Down
22 changes: 22 additions & 0 deletions tests/test_sanity_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pytest

from komodo.symlink.sanity_check import assert_root_nodes


def test_assert_root_nodes_error_message():
link_dict = {
"links": {
"stable": "2012.01",
"testing": "2012.03",
"missing_root_1": "2011.12",
"missing_root_2": "2011.11",
"missing_root_3": "2011.10",
},
"root_links": ["stable", "testing"],
}

with pytest.raises(
AssertionError,
match=r"Missing root\(s\): {(?=.*missing_root_1)(?=.*missing_root_2)(?=.*missing_root_3)",
):
assert_root_nodes(link_dict)

0 comments on commit 9a0d0d3

Please sign in to comment.