1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
from globus_sdk.scopes._graph_parser import ScopeGraph
def test_graph_str_single_node():
g = ScopeGraph.parse("foo")
clean_str = _blank_lines_removed(str(g))
assert (
clean_str
== """\
digraph scopes {
rankdir="LR";
foo
}"""
)
def test_graph_str_single_optional_node():
g = ScopeGraph.parse("*foo")
clean_str = _blank_lines_removed(str(g))
assert (
clean_str
== """\
digraph scopes {
rankdir="LR";
*foo
}"""
)
def test_graph_str_single_dependency():
g = ScopeGraph.parse("foo[bar]")
clean_str = _blank_lines_removed(str(g))
assert (
clean_str
== """\
digraph scopes {
rankdir="LR";
foo
foo -> bar;
}"""
)
def test_graph_str_optional_dependency():
g = ScopeGraph.parse("foo[bar[*baz]]")
clean_str = _blank_lines_removed(str(g))
assert (
clean_str
== """\
digraph scopes {
rankdir="LR";
foo
foo -> bar;
bar -> baz [ label = "optional" ];
}"""
)
def _blank_lines_removed(s: str) -> str:
return "\n".join(line for line in s.split("\n") if line.strip() != "")
|