Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_index_no_cache(tmpdir, cache_path):
runner = CliRunner()
result = runner.invoke(main.cli, ["--path", tmpdir, "--cache", cache_path, "index"])
assert result.exit_code == 1, result.stdout
def test_index_and_message_with_ipynb(ipynbbuilddir):
"""
Test that index works with a build
"""
runner = CliRunner()
result = runner.invoke(main.cli, ["--path", ipynbbuilddir, "index", "--message"])
assert result.stdout.count("An author") >= 3
assert "empty notebook" in result.stdout
assert "single cell" in result.stdout
assert "second cell" in result.stdout
assert result.exit_code == 0, result.stdout
def test_report_default_metrics(builddir):
"""
Test that report works with default metrics
"""
runner = CliRunner()
result = runner.invoke(main.cli, ["--path", builddir, "report", _path])
assert result.exit_code == 0, result.stdout
assert "Not found" not in result.stdout
def test_list_metrics_no_cache(tmpdir):
runner = CliRunner()
result = runner.invoke(main.cli, ["--path", tmpdir, "list-metrics"])
assert result.exit_code == 1, result.stdout
def test_rank_single_file_default_metric(builddir):
""" Test the rank feature with default (AimLow) metric on a single file """
runner = CliRunner()
result = runner.invoke(main.cli, ["--path", builddir, "rank", "src/test.py"])
assert result.exit_code == 0, result.stdout
def test_rank_no_cache(tmpdir):
""" Test the rank feature with no cache """
runner = CliRunner()
result = runner.invoke(main.cli, ["--path", tmpdir, "rank", "src/test.py"])
assert result.exit_code == 1, result.stdout
def test_index_with_ipynb(ipynbbuilddir):
"""
Test that index works with a build
"""
runner = CliRunner()
result = runner.invoke(main.cli, ["--path", ipynbbuilddir, "index"])
assert result.stdout.count("An author") >= 3
assert result.exit_code == 0, result.stdout
def test_diff_output_all(builddir):
""" Test the diff feature with no changes and the --all flag """
runner = CliRunner()
result = runner.invoke(
main.cli,
["--debug", "--path", builddir, "diff", _path, "--all"],
catch_exceptions=False,
)
assert result.exit_code == 0, result.stdout
assert "test.py" in result.stdout
with patch.object(
wily.commands.build.Bar, "finish", side_effect=RuntimeError("arggh")
) as bar_finish:
runner = CliRunner()
result = runner.invoke(main.cli, ["--path", tmpdir, "build", "test.py"])
assert bar_finish.called_once
assert result.exit_code == 1, result.stdout
with patch("wily.commands.build.logger") as logger:
logger.level = "DEBUG"
with patch.object(
wily.commands.build.Bar, "finish", side_effect=RuntimeError("arggh")
) as bar_finish:
runner = CliRunner()
result = runner.invoke(
main.cli, ["--debug", "--path", tmpdir, "build", "test.py"]
)
assert bar_finish.called_once
assert result.exit_code == 1, result.stdout
def test_index(builddir):
"""
Test that index works with a build
"""
runner = CliRunner()
result = runner.invoke(main.cli, ["--path", builddir, "index"])
assert result.exit_code == 0, result.stdout