From a1ebe663ce409e513a170d697b5c94de92b28c42 Mon Sep 17 00:00:00 2001 From: Qubasa Date: Tue, 12 Dec 2023 13:56:54 +0100 Subject: [PATCH] Fixing pytest --- pkgs/clan-cli/tests/test_flakes_cli.py | 39 ------------------- pkgs/clan-cli/tests/test_history_cli.py | 51 +++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 39 deletions(-) create mode 100644 pkgs/clan-cli/tests/test_history_cli.py diff --git a/pkgs/clan-cli/tests/test_flakes_cli.py b/pkgs/clan-cli/tests/test_flakes_cli.py index af483920a..bbaf23bd2 100644 --- a/pkgs/clan-cli/tests/test_flakes_cli.py +++ b/pkgs/clan-cli/tests/test_flakes_cli.py @@ -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 diff --git a/pkgs/clan-cli/tests/test_history_cli.py b/pkgs/clan-cli/tests/test_history_cli.py new file mode 100644 index 000000000..738160006 --- /dev/null +++ b/pkgs/clan-cli/tests/test_history_cli.py @@ -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 + +