api/flake/list_history: init
Add an api endpoint to list the history of clan flakes that have been interacted with Also add `clan flake list`
This commit is contained in:
@@ -23,6 +23,30 @@ def test_flake_add(
|
||||
assert open(user_history_file()).read().strip() == str(test_flake.path)
|
||||
|
||||
|
||||
def test_flake_list(
|
||||
api: TestClient, test_flake: FlakeForTest, temporary_home: Path
|
||||
) -> None:
|
||||
response = api.get(
|
||||
"/api/flake/list_history",
|
||||
)
|
||||
assert response.status_code == 200, response.text
|
||||
assert response.json() == []
|
||||
|
||||
# add the test_flake
|
||||
response = api.put(
|
||||
f"/api/flake/add?flake_dir={str(test_flake.path)}",
|
||||
json={},
|
||||
)
|
||||
assert response.status_code == 200, response.text
|
||||
|
||||
# list the flakes again
|
||||
response = api.get(
|
||||
"/api/flake/list_history",
|
||||
)
|
||||
assert response.status_code == 200, response.text
|
||||
assert response.json() == [str(test_flake.path)]
|
||||
|
||||
|
||||
@pytest.mark.impure
|
||||
def test_inspect_ok(api: TestClient, test_flake_with_core: FlakeForTest) -> None:
|
||||
params = {"url": str(test_flake_with_core.path)}
|
||||
|
||||
@@ -2,6 +2,7 @@ from typing import TYPE_CHECKING
|
||||
|
||||
from cli import Cli
|
||||
from fixtures_flakes import FlakeForTest
|
||||
from pytest import CaptureFixture
|
||||
|
||||
from clan_cli.dirs import user_history_file
|
||||
|
||||
@@ -24,3 +25,21 @@ def test_flakes_add(
|
||||
history_file = user_history_file()
|
||||
assert history_file.exists()
|
||||
assert open(history_file).read().strip() == str(test_flake.path)
|
||||
|
||||
|
||||
def test_flakes_list(
|
||||
capsys: CaptureFixture,
|
||||
test_flake: FlakeForTest,
|
||||
) -> None:
|
||||
cli = Cli()
|
||||
cmd = [
|
||||
"flakes",
|
||||
"list",
|
||||
]
|
||||
|
||||
cli.run(cmd)
|
||||
assert str(test_flake.path) not in capsys.readouterr().out
|
||||
|
||||
cli.run(["flakes", "add", str(test_flake.path)])
|
||||
cli.run(cmd)
|
||||
assert str(test_flake.path) in capsys.readouterr().out
|
||||
|
||||
Reference in New Issue
Block a user