diff options
author | Devaev Maxim <[email protected]> | 2019-04-08 19:19:26 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2019-04-08 19:19:26 +0300 |
commit | 3a68e82f94815660d23fa771e8d6fdbfdbb0bee6 (patch) | |
tree | 35549d5349e412e4bfb015623cb73458aded684a | |
parent | dda30309a48370bb3d82c8723993490972613223 (diff) |
refactoring
-rw-r--r-- | tests/test_aioregion.py | 8 | ||||
-rw-r--r-- | tests/test_app_cleanup.py | 2 | ||||
-rw-r--r-- | tests/test_app_htpasswd.py | 26 | ||||
-rw-r--r-- | tests/test_gpio.py | 6 | ||||
-rw-r--r-- | tests/test_keymap.py | 4 | ||||
-rw-r--r-- | tests/test_logging.py | 2 |
6 files changed, 24 insertions, 24 deletions
diff --git a/tests/test_aioregion.py b/tests/test_aioregion.py index dde0918b..6ce717fb 100644 --- a/tests/test_aioregion.py +++ b/tests/test_aioregion.py @@ -30,7 +30,7 @@ from kvmd.aioregion import AioExclusiveRegion # ===== @pytest.mark.asyncio -async def test_ok__aioregion__one(event_loop: asyncio.AbstractEventLoop) -> None: +async def test_ok__access_one(event_loop: asyncio.AbstractEventLoop) -> None: _ = event_loop region = AioExclusiveRegion(RegionIsBusyError) @@ -48,7 +48,7 @@ async def test_ok__aioregion__one(event_loop: asyncio.AbstractEventLoop) -> None @pytest.mark.asyncio -async def test_fail__aioregion__one(event_loop: asyncio.AbstractEventLoop) -> None: +async def test_fail__access_one(event_loop: asyncio.AbstractEventLoop) -> None: _ = event_loop region = AioExclusiveRegion(RegionIsBusyError) @@ -69,7 +69,7 @@ async def test_fail__aioregion__one(event_loop: asyncio.AbstractEventLoop) -> No # ===== @pytest.mark.asyncio -async def test_ok__aioregion__two(event_loop: asyncio.AbstractEventLoop) -> None: +async def test_ok__access_two(event_loop: asyncio.AbstractEventLoop) -> None: region = AioExclusiveRegion(RegionIsBusyError) async def func1() -> None: @@ -92,7 +92,7 @@ async def test_ok__aioregion__two(event_loop: asyncio.AbstractEventLoop) -> None @pytest.mark.asyncio -async def test_fail__aioregion__two(event_loop: asyncio.AbstractEventLoop) -> None: +async def test_fail__access_two(event_loop: asyncio.AbstractEventLoop) -> None: region = AioExclusiveRegion(RegionIsBusyError) async def func1() -> None: diff --git a/tests/test_app_cleanup.py b/tests/test_app_cleanup.py index 20f8fdac..a793e314 100644 --- a/tests/test_app_cleanup.py +++ b/tests/test_app_cleanup.py @@ -32,7 +32,7 @@ from kvmd.apps.cleanup import main # ===== -def test_main(tmpdir) -> None: # type: ignore +def test_ok(tmpdir) -> None: # type: ignore queue: multiprocessing.queues.Queue = multiprocessing.Queue() ustreamer_fake_name = "ustr-" + secrets.token_hex(3) diff --git a/tests/test_app_htpasswd.py b/tests/test_app_htpasswd.py index a7fe7395..8e8ddf8f 100644 --- a/tests/test_app_htpasswd.py +++ b/tests/test_app_htpasswd.py @@ -54,7 +54,7 @@ def _htpasswd_fixture(request) -> Generator[passlib.apache.HtpasswdFile, None, N os.remove(path) -def _run_main(htpasswd: passlib.apache.HtpasswdFile, cmd: List[str]) -> None: +def _run_htpasswd(htpasswd: passlib.apache.HtpasswdFile, cmd: List[str]) -> None: main([ "kvmd-htpasswd", *cmd, @@ -64,32 +64,32 @@ def _run_main(htpasswd: passlib.apache.HtpasswdFile, cmd: List[str]) -> None: # ===== -def test_ok__main_list(htpasswd: passlib.apache.HtpasswdFile, capsys) -> None: # type: ignore - _run_main(htpasswd, ["list"]) +def test_ok__list(htpasswd: passlib.apache.HtpasswdFile, capsys) -> None: # type: ignore + _run_htpasswd(htpasswd, ["list"]) (out, err) = capsys.readouterr() assert len(err) == 0 assert sorted(filter(None, out.split("\n"))) == sorted(htpasswd.users()) == sorted(set(htpasswd.users())) # ===== -def test_ok__main_set__change_stdin(htpasswd: passlib.apache.HtpasswdFile, mocker) -> None: # type: ignore +def test_ok__set_change_stdin(htpasswd: passlib.apache.HtpasswdFile, mocker) -> None: # type: ignore old_users = set(htpasswd.users()) if old_users: assert htpasswd.check_password("admin", _make_passwd("admin")) mocker.patch.object(builtins, "input", (lambda: " test ")) - _run_main(htpasswd, ["set", "admin", "--read-stdin"]) + _run_htpasswd(htpasswd, ["set", "admin", "--read-stdin"]) htpasswd.load(force=True) assert htpasswd.check_password("admin", " test ") assert old_users == set(htpasswd.users()) -def test_ok__main_set__add_stdin(htpasswd: passlib.apache.HtpasswdFile, mocker) -> None: # type: ignore +def test_ok__set_add_stdin(htpasswd: passlib.apache.HtpasswdFile, mocker) -> None: # type: ignore old_users = set(htpasswd.users()) if old_users: mocker.patch.object(builtins, "input", (lambda: " test ")) - _run_main(htpasswd, ["set", "new", "--read-stdin"]) + _run_htpasswd(htpasswd, ["set", "new", "--read-stdin"]) htpasswd.load(force=True) assert htpasswd.check_password("new", " test ") @@ -97,20 +97,20 @@ def test_ok__main_set__add_stdin(htpasswd: passlib.apache.HtpasswdFile, mocker) # ===== -def test_ok__main_set__change_getpass(htpasswd: passlib.apache.HtpasswdFile, mocker) -> None: # type: ignore +def test_ok__set_change_getpass(htpasswd: passlib.apache.HtpasswdFile, mocker) -> None: # type: ignore old_users = set(htpasswd.users()) if old_users: assert htpasswd.check_password("admin", _make_passwd("admin")) mocker.patch.object(getpass, "getpass", (lambda *_, **__: " test ")) - _run_main(htpasswd, ["set", "admin"]) + _run_htpasswd(htpasswd, ["set", "admin"]) htpasswd.load(force=True) assert htpasswd.check_password("admin", " test ") assert old_users == set(htpasswd.users()) -def test_fail__main_set__change_getpass(htpasswd: passlib.apache.HtpasswdFile, mocker) -> None: # type: ignore +def test_fail__set_change_getpass(htpasswd: passlib.apache.HtpasswdFile, mocker) -> None: # type: ignore old_users = set(htpasswd.users()) if old_users: assert htpasswd.check_password("admin", _make_passwd("admin")) @@ -129,7 +129,7 @@ def test_fail__main_set__change_getpass(htpasswd: passlib.apache.HtpasswdFile, m mocker.patch.object(getpass, "getpass", fake_getpass) with pytest.raises(SystemExit, match="Sorry, passwords do not match"): - _run_main(htpasswd, ["set", "admin"]) + _run_htpasswd(htpasswd, ["set", "admin"]) assert count == 2 htpasswd.load(force=True) @@ -138,13 +138,13 @@ def test_fail__main_set__change_getpass(htpasswd: passlib.apache.HtpasswdFile, m # ===== -def test_ok__main_del(htpasswd: passlib.apache.HtpasswdFile) -> None: +def test_ok__del(htpasswd: passlib.apache.HtpasswdFile) -> None: old_users = set(htpasswd.users()) if old_users: assert htpasswd.check_password("admin", _make_passwd("admin")) - _run_main(htpasswd, ["del", "admin"]) + _run_htpasswd(htpasswd, ["del", "admin"]) htpasswd.load(force=True) assert not htpasswd.check_password("admin", _make_passwd("admin")) diff --git a/tests/test_gpio.py b/tests/test_gpio.py index b5197590..f930f92f 100644 --- a/tests/test_gpio.py +++ b/tests/test_gpio.py @@ -24,7 +24,7 @@ from kvmd import gpio # ===== -def test_gpio__loopback_initial_false() -> None: +def test_ok__loopback_initial_false() -> None: # pylint: disable=singleton-comparison with gpio.bcm(): assert gpio.set_output(0) == 0 @@ -33,7 +33,7 @@ def test_gpio__loopback_initial_false() -> None: assert gpio.read(0) is True -def test_gpio__loopback_initial_true() -> None: +def test_ok__loopback_initial_true() -> None: # pylint: disable=singleton-comparison with gpio.bcm(): assert gpio.set_output(0, True) == 0 @@ -42,7 +42,7 @@ def test_gpio__loopback_initial_true() -> None: assert gpio.read(0) is False -def test_gpio__input() -> None: +def test_ok__input() -> None: # pylint: disable=singleton-comparison with gpio.bcm(): assert gpio.set_input(0) == 0 diff --git a/tests/test_keymap.py b/tests/test_keymap.py index 26251fdb..f69accb1 100644 --- a/tests/test_keymap.py +++ b/tests/test_keymap.py @@ -26,11 +26,11 @@ from kvmd.keymap import KEYMAP # ===== -def test_keymap__ok() -> None: +def test_ok__keymap() -> None: assert type(KEYMAP["KeyA"]) == int # pylint: disable=unidiomatic-typecheck assert KEYMAP["KeyA"] == 1 -def test_keymap__fail() -> None: +def test_fail__keymap() -> None: with pytest.raises(KeyError): print(KEYMAP["keya"]) diff --git a/tests/test_logging.py b/tests/test_logging.py index be6b889e..e6372e33 100644 --- a/tests/test_logging.py +++ b/tests/test_logging.py @@ -31,5 +31,5 @@ from kvmd.logging import get_logger (1, "_pytest.python"), (2, "pluggy.callers"), ]) -def test_get_logger(depth: int, name: str) -> None: +def test_ok__get_logger(depth: int, name: str) -> None: assert get_logger(depth).name == name |