Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions test/test_edit.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
from pathlib import Path
from unittest.mock import Mock, patch

import typer
from typer import testing

from repo_man.cli import cli


def test_edit_clean(runner: typer.testing.CliRunner) -> None:
def test_edit_clean(runner: testing.CliRunner) -> None:
with runner.isolated_filesystem():
result = runner.invoke(cli, ["edit"])
assert result.exit_code == 1
assert result.output == "No repo-man.cfg file found.\n"


@patch("repo_man.commands.edit.typer.edit")
def test_edit_when_config_present(mock_edit: Mock, runner: typer.testing.CliRunner) -> None:
def test_edit_when_config_present(mock_edit: Mock, runner: testing.CliRunner) -> None:
with runner.isolated_filesystem():
Path("repo-man.cfg").touch()
result = runner.invoke(cli, ["edit"])
Expand Down
8 changes: 4 additions & 4 deletions test/test_implode.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from pathlib import Path

import typer
from typer import testing

from repo_man.cli import cli


def test_implode_when_config_present_confirm(runner: typer.testing.CliRunner) -> None:
def test_implode_when_config_present_confirm(runner: testing.CliRunner) -> None:
with runner.isolated_filesystem():
Path("repo-man.cfg").touch()

Expand All @@ -15,14 +15,14 @@ def test_implode_when_config_present_confirm(runner: typer.testing.CliRunner) ->
assert not Path("repo-man.cfg").exists()


def test_implode_when_config_not_present_confirm(runner: typer.testing.CliRunner) -> None:
def test_implode_when_config_not_present_confirm(runner: testing.CliRunner) -> None:
with runner.isolated_filesystem():
result = runner.invoke(cli, ["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: typer.testing.CliRunner) -> None:
def test_implode_when_config_present_no_confirm(runner: testing.CliRunner) -> None:
with runner.isolated_filesystem():
Path("repo-man.cfg").touch()

Expand Down
8 changes: 4 additions & 4 deletions test/test_init.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from pathlib import Path

import typer
from typer import testing

from repo_man.cli import cli


def test_init_clean(runner: typer.testing.CliRunner) -> None:
def test_init_clean(runner: testing.CliRunner) -> None:
with runner.isolated_filesystem():
assert not Path("repo-man.cfg").exists()

Expand All @@ -15,7 +15,7 @@ def test_init_clean(runner: typer.testing.CliRunner) -> None:
assert Path("repo-man.cfg").exists()


def test_init_with_existing_confirm(runner: typer.testing.CliRunner) -> None:
def test_init_with_existing_confirm(runner: testing.CliRunner) -> None:
with runner.isolated_filesystem():
with open("repo-man.cfg", "w") as config_file:
config_file.write(
Expand All @@ -33,7 +33,7 @@ def test_init_with_existing_confirm(runner: typer.testing.CliRunner) -> None:
assert config_file.read() == ""


def test_init_with_existing_no_confirm(runner: typer.testing.CliRunner) -> None:
def test_init_with_existing_no_confirm(runner: testing.CliRunner) -> None:
with runner.isolated_filesystem():
with open("repo-man.cfg", "w") as config_file:
config_file.write(
Expand Down
12 changes: 6 additions & 6 deletions test/test_list_repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from collections.abc import Callable
from unittest.mock import Mock, patch

import typer
from typer import testing

from repo_man.cli import cli


def test_list_repos_clean(runner: typer.testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]) -> None:
def test_list_repos_clean(runner: testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]) -> None:
with runner.isolated_filesystem():
config = get_config()
result = runner.invoke(cli, ["list", "-t", "all"], obj=config)
Expand All @@ -16,7 +16,7 @@ def test_list_repos_clean(runner: typer.testing.CliRunner, get_config: Callable[


def test_list_repos_with_matches(
runner: typer.testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]
runner: testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]
) -> None:
with runner.isolated_filesystem():
with open("repo-man.cfg", "w") as config_file:
Expand All @@ -42,7 +42,7 @@ def test_list_repos_with_matches(

@patch("repo_man.commands.list_repos.click.echo_via_pager")
def test_list_repos_when_long(
mock_echo_via_pager: Mock, runner: typer.testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]
mock_echo_via_pager: Mock, runner: testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]
) -> None:
all_repos = """some-repo-1
some-repo-2
Expand Down Expand Up @@ -90,7 +90,7 @@ def test_list_repos_when_long(


def test_list_repos_for_multiple_tags(
runner: typer.testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]
runner: testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]
) -> None:
with runner.isolated_filesystem():
with open("repo-man.cfg", "w") as config_file:
Expand Down Expand Up @@ -118,7 +118,7 @@ def test_list_repos_for_multiple_tags(


def test_list_repos_when_invalid_type(
runner: typer.testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]
runner: testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]
) -> None:
with runner.isolated_filesystem():
with open("repo-man.cfg", "w") as config_file:
Expand Down
8 changes: 4 additions & 4 deletions test/test_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from collections.abc import Callable
from pathlib import Path

import typer
from typer import testing

from repo_man.cli import cli


def test_remove_clean(runner: typer.testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]) -> None:
def test_remove_clean(runner: testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]) -> None:
with runner.isolated_filesystem():
Path("some-repo").mkdir()

Expand All @@ -29,7 +29,7 @@ def test_remove_clean(runner: typer.testing.CliRunner, get_config: Callable[[],


def test_remove_when_invalid_type(
runner: typer.testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]
runner: testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]
) -> None:
with runner.isolated_filesystem():
Path("some-repo").mkdir()
Expand Down Expand Up @@ -61,7 +61,7 @@ def test_remove_when_invalid_type(


def test_remove_when_unused_type(
runner: typer.testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]
runner: testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]
) -> None:
with runner.isolated_filesystem():
Path("some-repo").mkdir()
Expand Down
8 changes: 4 additions & 4 deletions test/test_sniff.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from collections.abc import Callable
from pathlib import Path

import typer
from typer import testing

from repo_man.cli import cli


def test_known(runner: typer.testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]) -> None:
def test_known(runner: testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]) -> None:
with runner.isolated_filesystem():
with open("repo-man.cfg", "w") as config_file:
config_file.write(
Expand All @@ -34,7 +34,7 @@ def test_known(runner: typer.testing.CliRunner, get_config: Callable[[], configp
assert result.output == "bar\nfoo\n"


def test_unconfigured(runner: typer.testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]) -> None:
def test_unconfigured(runner: testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]) -> None:
with runner.isolated_filesystem():
Path("some-repo").mkdir()
Path("some-other-repo").mkdir()
Expand All @@ -55,7 +55,7 @@ def test_unconfigured(runner: typer.testing.CliRunner, get_config: Callable[[],
assert result.output == "some-other-repo\n"


def test_duplicates(runner: typer.testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]) -> None:
def test_duplicates(runner: testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]) -> None:
with runner.isolated_filesystem():
with open("repo-man.cfg", "w") as config_file:
config_file.write(
Expand Down
14 changes: 5 additions & 9 deletions test/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from collections.abc import Callable
from pathlib import Path

import typer
from typer import testing

from repo_man.cli import cli


def test_types_clean(runner: typer.testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]) -> None:
def test_types_clean(runner: testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]) -> None:
with runner.isolated_filesystem():
Path("some-repo").mkdir()
config = get_config()
Expand All @@ -16,9 +16,7 @@ def test_types_clean(runner: typer.testing.CliRunner, get_config: Callable[[], c
assert result.output == "No repo-man.cfg file found.\n"


def test_types_when_configured(
runner: typer.testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]
) -> None:
def test_types_when_configured(runner: testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]) -> None:
with runner.isolated_filesystem():
Path("some-repo").mkdir()

Expand All @@ -42,7 +40,7 @@ def test_types_when_configured(


def test_types_when_not_configured(
runner: typer.testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]
runner: testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]
) -> None:
with runner.isolated_filesystem():
Path("some-repo").mkdir()
Expand All @@ -62,9 +60,7 @@ def test_types_when_not_configured(
assert result.output == ""


def test_types_when_ignored(
runner: typer.testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]
) -> None:
def test_types_when_ignored(runner: testing.CliRunner, get_config: Callable[[], configparser.ConfigParser]) -> None:
with runner.isolated_filesystem():
Path("some-repo").mkdir()

Expand Down
4 changes: 2 additions & 2 deletions test/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import typer
from typer import testing

from repo_man.utils import get_valid_repo_types


def test_get_valid_repo_types(runner: typer.testing.CliRunner) -> None:
def test_get_valid_repo_types(runner: testing.CliRunner) -> None:
with runner.isolated_filesystem():
with open("repo-man.cfg", "w") as config_file:
config_file.write(
Expand Down
4 changes: 2 additions & 2 deletions test/test_version.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from unittest.mock import patch

import typer
from typer import testing

from repo_man.cli import cli


@patch("repo_man.cli.RELEASE_VERSION", "0.0.0")
def test_version(runner: typer.testing.CliRunner) -> None:
def test_version(runner: testing.CliRunner) -> None:
result = runner.invoke(cli, ["--version"])
assert result.exit_code == 0
assert result.output.strip() == "0.0.0"