1
0
forked from clan/clan-core

Fixing pytest

This commit is contained in:
Luis Hebendanz 2023-12-12 13:56:54 +01:00
parent b00f4554d8
commit a1ebe663ce
2 changed files with 51 additions and 39 deletions

View File

@ -6,49 +6,10 @@ from cli import Cli
from fixtures_flakes import FlakeForTest
from pytest import CaptureFixture
from clan_cli.dirs import user_history_file
from clan_cli.history.add import HistoryEntry
if TYPE_CHECKING:
pass
def test_flakes_add(
test_flake: FlakeForTest,
) -> None:
cli = Cli()
cmd = [
"flakes",
"add",
str(test_flake.path),
]
cli.run(cmd)
history_file = user_history_file()
assert history_file.exists()
history = [HistoryEntry(**entry) for entry in json.loads(open(history_file).read())]
assert history[0].path == 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
@pytest.mark.impure
def test_flakes_inspect(
test_flake_with_core: FlakeForTest, capsys: pytest.CaptureFixture

View File

@ -0,0 +1,51 @@
import json
from typing import TYPE_CHECKING
import pytest
from cli import Cli
from fixtures_flakes import FlakeForTest
from pytest import CaptureFixture
from clan_cli.dirs import user_history_file
from clan_cli.history.add import HistoryEntry
if TYPE_CHECKING:
pass
def test_history_add(
test_flake: FlakeForTest,
) -> None:
cli = Cli()
cmd = [
"history",
"add",
str(test_flake.path),
]
cli.run(cmd)
history_file = user_history_file()
assert history_file.exists()
history = [HistoryEntry(**entry) for entry in json.loads(open(history_file).read())]
assert history[0].path == str(test_flake.path)
def test_history_list(
capsys: CaptureFixture,
test_flake: FlakeForTest,
) -> None:
cli = Cli()
cmd = [
"history",
"list",
]
cli.run(cmd)
assert str(test_flake.path) not in capsys.readouterr().out
cli.run(["history", "add", str(test_flake.path)])
cli.run(cmd)
assert str(test_flake.path) in capsys.readouterr().out