mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 17:20:30 +08:00
refactoring
This commit is contained in:
parent
28c556d92e
commit
7eca51f17b
@ -30,7 +30,7 @@ from kvmd.aioregion import AioExclusiveRegion
|
||||
|
||||
# =====
|
||||
@pytest.mark.asyncio
|
||||
async def test_aioregion__one__ok(event_loop: asyncio.AbstractEventLoop) -> None:
|
||||
async def test_ok__aioregion__one(event_loop: asyncio.AbstractEventLoop) -> None:
|
||||
_ = event_loop
|
||||
region = AioExclusiveRegion(RegionIsBusyError)
|
||||
|
||||
@ -48,7 +48,7 @@ async def test_aioregion__one__ok(event_loop: asyncio.AbstractEventLoop) -> None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_aioregion__one__fail(event_loop: asyncio.AbstractEventLoop) -> None:
|
||||
async def test_fail__aioregion__one(event_loop: asyncio.AbstractEventLoop) -> None:
|
||||
_ = event_loop
|
||||
region = AioExclusiveRegion(RegionIsBusyError)
|
||||
|
||||
@ -69,7 +69,7 @@ async def test_aioregion__one__fail(event_loop: asyncio.AbstractEventLoop) -> No
|
||||
|
||||
# =====
|
||||
@pytest.mark.asyncio
|
||||
async def test_aioregion__two__ok(event_loop: asyncio.AbstractEventLoop) -> None:
|
||||
async def test_ok__aioregion__two(event_loop: asyncio.AbstractEventLoop) -> None:
|
||||
region = AioExclusiveRegion(RegionIsBusyError)
|
||||
|
||||
async def func1() -> None:
|
||||
@ -92,7 +92,7 @@ async def test_aioregion__two__ok(event_loop: asyncio.AbstractEventLoop) -> None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_aioregion__two__fail(event_loop: asyncio.AbstractEventLoop) -> None:
|
||||
async def test_fail__aioregion__two(event_loop: asyncio.AbstractEventLoop) -> None:
|
||||
region = AioExclusiveRegion(RegionIsBusyError)
|
||||
|
||||
async def func1() -> None:
|
||||
|
||||
@ -64,7 +64,7 @@ def _run_main(htpasswd: passlib.apache.HtpasswdFile, cmd: List[str]) -> None:
|
||||
|
||||
|
||||
# =====
|
||||
def test_main__list(htpasswd: passlib.apache.HtpasswdFile, capsys) -> None: # type: ignore
|
||||
def test_ok__main_list(htpasswd: passlib.apache.HtpasswdFile, capsys) -> None: # type: ignore
|
||||
_run_main(htpasswd, ["list"])
|
||||
(out, err) = capsys.readouterr()
|
||||
assert len(err) == 0
|
||||
@ -72,7 +72,7 @@ def test_main__list(htpasswd: passlib.apache.HtpasswdFile, capsys) -> None: # t
|
||||
|
||||
|
||||
# =====
|
||||
def test_main__set__change_stdin(htpasswd: passlib.apache.HtpasswdFile, mocker) -> None: # type: ignore
|
||||
def test_ok__main_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"))
|
||||
@ -85,7 +85,7 @@ def test_main__set__change_stdin(htpasswd: passlib.apache.HtpasswdFile, mocker)
|
||||
assert old_users == set(htpasswd.users())
|
||||
|
||||
|
||||
def test_main__set__add_stdin(htpasswd: passlib.apache.HtpasswdFile, mocker) -> None: # type: ignore
|
||||
def test_ok__main_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 "))
|
||||
@ -97,7 +97,7 @@ def test_main__set__add_stdin(htpasswd: passlib.apache.HtpasswdFile, mocker) ->
|
||||
|
||||
|
||||
# =====
|
||||
def test_main__set__change_getpass__ok(htpasswd: passlib.apache.HtpasswdFile, mocker) -> None: # type: ignore
|
||||
def test_ok__main_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"))
|
||||
@ -110,7 +110,7 @@ def test_main__set__change_getpass__ok(htpasswd: passlib.apache.HtpasswdFile, mo
|
||||
assert old_users == set(htpasswd.users())
|
||||
|
||||
|
||||
def test_main__set__change_getpass__fail(htpasswd: passlib.apache.HtpasswdFile, mocker) -> None: # type: ignore
|
||||
def test_fail__main_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"))
|
||||
@ -138,7 +138,7 @@ def test_main__set__change_getpass__fail(htpasswd: passlib.apache.HtpasswdFile,
|
||||
|
||||
|
||||
# =====
|
||||
def test_main__del(htpasswd: passlib.apache.HtpasswdFile) -> None:
|
||||
def test_ok__main_del(htpasswd: passlib.apache.HtpasswdFile) -> None:
|
||||
old_users = set(htpasswd.users())
|
||||
|
||||
if old_users:
|
||||
|
||||
@ -79,7 +79,7 @@ def test_ok__valid_ip(arg: Any) -> None:
|
||||
"",
|
||||
None,
|
||||
])
|
||||
def test__fail_valid_ip(arg: Any) -> None:
|
||||
def test_fail__valid_ip(arg: Any) -> None:
|
||||
with pytest.raises(ValidatorError):
|
||||
print(valid_ip(arg))
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user