mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2026-11-07 21:32:25 +00:00
Add CLI and API endpoint tests
This commit is contained in:
1 parent
1e02b1a670
commit
64b47d3e68
3 files changed
+267
No files matched your search
@@ -0,0 +1,44 @@
|
||||
import pytest
|
||||
from types import SimpleNamespace
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from seedpass.cli import app
|
||||
from seedpass import cli
|
||||
|
||||
runner = CliRunner()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"key,value,method,expected",
|
||||
[
|
||||
("secret_mode_enabled", "true", "set_secret_mode_enabled", True),
|
||||
("clipboard_clear_delay", "10", "set_clipboard_clear_delay", 10),
|
||||
("additional_backup_path", "", "set_additional_backup_path", None),
|
||||
(
|
||||
"relays",
|
||||
"wss://a.com, wss://b.com",
|
||||
"set_relays",
|
||||
["wss://a.com", "wss://b.com"],
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_config_set_variants(monkeypatch, key, value, method, expected):
|
||||
called = {}
|
||||
|
||||
def func(val, **kwargs):
|
||||
called["val"] = val
|
||||
called.update(kwargs)
|
||||
|
||||
pm = SimpleNamespace(
|
||||
config_manager=SimpleNamespace(**{method: func}),
|
||||
select_fingerprint=lambda fp: None,
|
||||
)
|
||||
monkeypatch.setattr(cli, "PasswordManager", lambda: pm)
|
||||
|
||||
result = runner.invoke(app, ["config", "set", key, value])
|
||||
|
||||
assert result.exit_code == 0
|
||||
assert "Updated" in result.stdout
|
||||
assert called.get("val") == expected
|
||||
if key == "relays":
|
||||
assert called.get("require_pin") is False
|
||||
Reference in new issue
Block a user