mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-08 07:18:47 +00:00
Merge pull request #465 from PR0M3TH3AN/codex/add-tests-for-cli-entry-add-commands
Ensure CLI add commands trigger sync
This commit is contained in:
@@ -11,6 +11,22 @@ runner = CliRunner()
|
|||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"command,method,cli_args,expected_args,expected_kwargs,stdout",
|
"command,method,cli_args,expected_args,expected_kwargs,stdout",
|
||||||
[
|
[
|
||||||
|
(
|
||||||
|
"add",
|
||||||
|
"add_entry",
|
||||||
|
[
|
||||||
|
"Label",
|
||||||
|
"--length",
|
||||||
|
"16",
|
||||||
|
"--username",
|
||||||
|
"user",
|
||||||
|
"--url",
|
||||||
|
"https://example.com",
|
||||||
|
],
|
||||||
|
("Label", 16, "user", "https://example.com"),
|
||||||
|
{},
|
||||||
|
"1",
|
||||||
|
),
|
||||||
(
|
(
|
||||||
"add-totp",
|
"add-totp",
|
||||||
"add_totp",
|
"add_totp",
|
||||||
@@ -99,11 +115,14 @@ def test_entry_add_commands(
|
|||||||
called["kwargs"] = kwargs
|
called["kwargs"] = kwargs
|
||||||
return stdout
|
return stdout
|
||||||
|
|
||||||
|
def sync_vault():
|
||||||
|
called["sync"] = True
|
||||||
|
|
||||||
pm = SimpleNamespace(
|
pm = SimpleNamespace(
|
||||||
entry_manager=SimpleNamespace(**{method: func}),
|
entry_manager=SimpleNamespace(**{method: func}),
|
||||||
parent_seed="seed",
|
parent_seed="seed",
|
||||||
select_fingerprint=lambda fp: None,
|
select_fingerprint=lambda fp: None,
|
||||||
sync_vault=lambda: None,
|
sync_vault=sync_vault,
|
||||||
)
|
)
|
||||||
monkeypatch.setattr(cli, "PasswordManager", lambda: pm)
|
monkeypatch.setattr(cli, "PasswordManager", lambda: pm)
|
||||||
result = runner.invoke(app, ["entry", command] + cli_args)
|
result = runner.invoke(app, ["entry", command] + cli_args)
|
||||||
@@ -111,3 +130,4 @@ def test_entry_add_commands(
|
|||||||
assert stdout in result.stdout
|
assert stdout in result.stdout
|
||||||
assert called["args"] == expected_args
|
assert called["args"] == expected_args
|
||||||
assert called["kwargs"] == expected_kwargs
|
assert called["kwargs"] == expected_kwargs
|
||||||
|
assert called.get("sync") is True
|
||||||
|
Reference in New Issue
Block a user