Fixing pytest
This commit is contained in:
@@ -6,49 +6,10 @@ from cli import Cli
|
|||||||
from fixtures_flakes import FlakeForTest
|
from fixtures_flakes import FlakeForTest
|
||||||
from pytest import CaptureFixture
|
from pytest import CaptureFixture
|
||||||
|
|
||||||
from clan_cli.dirs import user_history_file
|
|
||||||
from clan_cli.history.add import HistoryEntry
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
pass
|
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
|
@pytest.mark.impure
|
||||||
def test_flakes_inspect(
|
def test_flakes_inspect(
|
||||||
test_flake_with_core: FlakeForTest, capsys: pytest.CaptureFixture
|
test_flake_with_core: FlakeForTest, capsys: pytest.CaptureFixture
|
||||||
|
|||||||
51
pkgs/clan-cli/tests/test_history_cli.py
Normal file
51
pkgs/clan-cli/tests/test_history_cli.py
Normal 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
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user