-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Reach full unit test coverage * Cover paged output scenario * Update changelog * Reformat files * Bump version and changelog * Add coverage threshold
- Loading branch information
Showing
14 changed files
with
336 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import configparser | ||
|
||
import pytest | ||
from click.testing import CliRunner | ||
|
||
from repo_man.consts import REPO_TYPES_CFG | ||
|
||
|
||
@pytest.fixture | ||
def runner(): | ||
return CliRunner() | ||
|
||
|
||
@pytest.fixture | ||
def get_config(): | ||
def func(): | ||
config = configparser.ConfigParser() | ||
config.read(REPO_TYPES_CFG) | ||
return config | ||
|
||
return func |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from pathlib import Path | ||
from unittest.mock import patch | ||
|
||
from repo_man.commands import edit | ||
|
||
|
||
def test_edit_clean(runner): | ||
with runner.isolated_filesystem(): | ||
result = runner.invoke(edit.edit) | ||
assert result.exit_code == 1 | ||
assert result.output == "No repo-man.cfg file found.\n" | ||
|
||
|
||
@patch("repo_man.commands.edit.click.edit") | ||
def test_edit_when_config_present(mock_edit, runner): | ||
with runner.isolated_filesystem(): | ||
Path("repo-man.cfg").touch() | ||
result = runner.invoke(edit.edit) | ||
assert result.exit_code == 0 | ||
assert result.output == "" | ||
mock_edit.assert_called_once_with(filename="repo-man.cfg") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
from pathlib import Path | ||
|
||
from repo_man.commands.flavors import flavors | ||
|
||
|
||
def test_flavors_clean(runner, get_config): | ||
with runner.isolated_filesystem(): | ||
Path("some-repo").mkdir() | ||
config = get_config() | ||
result = runner.invoke(flavors, ["some-repo"], obj=config) | ||
assert result.exit_code == 1 | ||
assert result.output == "No repo-man.cfg file found.\n" | ||
|
||
|
||
def test_flavors_when_configured(runner, get_config): | ||
with runner.isolated_filesystem(): | ||
Path("some-repo").mkdir() | ||
|
||
with open("repo-man.cfg", "w") as config_file: | ||
config_file.write( | ||
"""[foo] | ||
known = | ||
some-repo | ||
[ignore] | ||
known = | ||
some-other-repo | ||
""" | ||
) | ||
|
||
config = get_config() | ||
result = runner.invoke(flavors, ["some-repo"], obj=config) | ||
assert result.exit_code == 0 | ||
assert result.output == "foo\n" | ||
|
||
|
||
def test_flavors_when_not_configured(runner, get_config): | ||
with runner.isolated_filesystem(): | ||
Path("some-repo").mkdir() | ||
|
||
with open("repo-man.cfg", "w") as config_file: | ||
config_file.write( | ||
"""[foo] | ||
known = | ||
some-other-repo | ||
""" | ||
) | ||
|
||
config = get_config() | ||
result = runner.invoke(flavors, ["some-repo"], obj=config) | ||
assert result.exit_code == 0 | ||
assert result.output == "" | ||
|
||
|
||
def test_flavors_when_ignored(runner, get_config): | ||
with runner.isolated_filesystem(): | ||
Path("some-repo").mkdir() | ||
|
||
with open("repo-man.cfg", "w") as config_file: | ||
config_file.write( | ||
"""[ignore] | ||
known = | ||
some-repo | ||
""" | ||
) | ||
|
||
config = get_config() | ||
result = runner.invoke(flavors, ["some-repo"], obj=config) | ||
assert result.exit_code == 0 | ||
assert result.output == "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from pathlib import Path | ||
|
||
from repo_man.commands.implode import implode | ||
|
||
|
||
def test_implode_when_config_present_confirm(runner): | ||
with runner.isolated_filesystem(): | ||
Path("repo-man.cfg").touch() | ||
|
||
result = runner.invoke(implode, ["."], input="Y\n") | ||
assert result.exit_code == 0 | ||
assert result.output == "Are you sure you want to do this? [y/N]: Y\n" | ||
assert not Path("repo-man.cfg").exists() | ||
|
||
|
||
def test_implode_when_config_not_present_confirm(runner): | ||
with runner.isolated_filesystem(): | ||
result = runner.invoke(implode, ["."], input="Y\n") | ||
assert result.exit_code == 0 | ||
assert result.output == "Are you sure you want to do this? [y/N]: Y\n" | ||
|
||
|
||
def test_implode_when_config_present_no_confirm(runner): | ||
with runner.isolated_filesystem(): | ||
Path("repo-man.cfg").touch() | ||
|
||
result = runner.invoke(implode, ["."], input="\n") | ||
assert result.exit_code == 1 | ||
assert ( | ||
result.output | ||
== """Are you sure you want to do this? [y/N]: | ||
Aborted! | ||
""" | ||
) | ||
assert Path("repo-man.cfg").exists() |
Oops, something went wrong.