Skip to content

Commit

Permalink
Fix tests, add new test for graph with multiple paths.
Browse files Browse the repository at this point in the history
  • Loading branch information
devdanzin committed Aug 16, 2023
1 parent 15ccc1e commit b528da0
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions test/unit/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,32 @@ def test_graph():
with patch("wily.__main__.exists", return_value=True) as check_cache:
with patch("wily.commands.graph.graph") as graph:
runner = CliRunner()
result = runner.invoke(main.cli, ["graph", "foo.py", "example_metric"])
result = runner.invoke(
main.cli, ["graph", "foo.py", "-m", "example_metric"]
)
assert result.exit_code == 0
assert graph.called_once
assert check_cache.called_once
assert graph.call_args[1]["path"] == ("foo.py",)
assert graph.call_args[1]["metrics"] == "example_metric"


def test_graph_multiple_paths():
"""
Test that graph calls the graph command with multiple paths
"""
with patch("wily.__main__.exists", return_value=True) as check_cache:
with patch("wily.commands.graph.graph") as graph:
runner = CliRunner()
result = runner.invoke(
main.cli,
["graph", "foo.py", "bar.py", "baz.py", "-m", "example_metric"],
)
assert result.exit_code == 0
assert graph.called_once
assert check_cache.called_once
assert graph.call_args[1]["path"] == "foo.py"
assert graph.call_args[1]["metrics"] == ("example_metric",)
assert graph.call_args[1]["path"] == ("foo.py", "bar.py", "baz.py")
assert graph.call_args[1]["metrics"] == "example_metric"


def test_graph_multiple_metrics():
Expand All @@ -303,13 +323,13 @@ def test_graph_multiple_metrics():
with patch("wily.commands.graph.graph") as graph:
runner = CliRunner()
result = runner.invoke(
main.cli, ["graph", "foo.py", "example_metric", "another_metric"]
main.cli, ["graph", "foo.py", "-m", "example_metric,another_metric"]
)
assert result.exit_code == 0
assert graph.called_once
assert check_cache.called_once
assert graph.call_args[1]["path"] == "foo.py"
assert graph.call_args[1]["metrics"] == ("example_metric", "another_metric")
assert graph.call_args[1]["path"] == ("foo.py",)
assert graph.call_args[1]["metrics"] == "example_metric,another_metric"


def test_graph_with_output():
Expand All @@ -320,13 +340,13 @@ def test_graph_with_output():
with patch("wily.commands.graph.graph") as graph:
runner = CliRunner()
result = runner.invoke(
main.cli, ["graph", "foo.py", "example_metric", "-o", "foo.html"]
main.cli, ["graph", "foo.py", "-m", "example_metric", "-o", "foo.html"]
)
assert result.exit_code == 0
assert graph.called_once
assert check_cache.called_once
assert graph.call_args[1]["path"] == "foo.py"
assert graph.call_args[1]["metrics"] == ("example_metric",)
assert graph.call_args[1]["path"] == ("foo.py",)
assert graph.call_args[1]["metrics"] == "example_metric"
assert graph.call_args[1]["output"] == "foo.html"


Expand Down

0 comments on commit b528da0

Please sign in to comment.