Added clan flakes inspect command. Improved ClanURI. Added democlan as dependency in flake.nix

This commit is contained in:
Qubasa
2023-12-09 00:04:56 +01:00
parent 9f4ab67fc2
commit d4b8cef242
14 changed files with 406 additions and 41 deletions

View File

@@ -118,6 +118,24 @@ def test_flake_with_core(
)
@pytest.fixture
def test_local_democlan(
monkeypatch: pytest.MonkeyPatch, temporary_home: Path
) -> Iterator[FlakeForTest]:
democlan = os.getenv(key="DEMOCLAN_ROOT")
if democlan is None:
raise Exception(
"DEMOCLAN_ROOT not set. This test requires the democlan flake to be present"
)
democlan_p = Path(democlan).resolve()
if not democlan_p.is_dir():
raise Exception(
f"DEMOCLAN_ROOT ({democlan_p}) is not a directory. This test requires the democlan directory to be present"
)
yield FlakeForTest(democlan_p)
@pytest.fixture
def test_democlan_url(
monkeypatch: pytest.MonkeyPatch, temporary_home: Path

View File

@@ -6,6 +6,21 @@ from clan_cli.clan_uri import ClanParameters, ClanScheme, ClanURI
from clan_cli.errors import ClanError
def test_get_internal() -> None:
# Create a ClanURI object from a remote URI with parameters
uri = ClanURI("clan://https://example.com?flake_attr=myVM&password=1234")
assert uri.get_internal() == "https://example.com?password=1234"
uri = ClanURI("clan://~/Downloads")
assert uri.get_internal() == "~/Downloads"
uri = ClanURI("clan:///home/user/Downloads")
assert uri.get_internal() == "/home/user/Downloads"
uri = ClanURI("clan://file:///home/user/Downloads")
assert uri.get_internal() == "/home/user/Downloads"
def test_local_uri() -> None:
# Create a ClanURI object from a local URI
uri = ClanURI("clan://file:///home/user/Downloads")

View File

@@ -1,6 +1,7 @@
import json
from typing import TYPE_CHECKING
import pytest
from cli import Cli
from fixtures_flakes import FlakeForTest
from pytest import CaptureFixture
@@ -46,3 +47,23 @@ def test_flakes_list(
cli.run(["flakes", "add", str(test_flake.path)])
cli.run(cmd)
assert str(test_flake.path) in capsys.readouterr().out
@pytest.mark.impure
def test_flakes_inspect(
test_flake_with_core: FlakeForTest, capsys: pytest.CaptureFixture
) -> None:
cli = Cli()
cli.run(
[
"--flake",
str(test_flake_with_core.path),
"flakes",
"inspect",
"--machine",
"vm1",
]
)
out = capsys.readouterr() # empty the buffer
assert "Icon" in out.out

View File

@@ -3,26 +3,6 @@ import deal
from clan_cli import nix
@deal.cases(nix.nix_command)
def test_nix_command(case: deal.TestCase) -> None:
case()
@deal.cases(nix.nix_build)
def test_nix_build(case: deal.TestCase) -> None:
case()
@deal.cases(nix.nix_config)
def test_nix_config(case: deal.TestCase) -> None:
case()
@deal.cases(nix.nix_eval)
def test_nix_eval(case: deal.TestCase) -> None:
case()
@deal.cases(nix.nix_shell)
def test_nix_shell(case: deal.TestCase) -> None:
case()