1
0
forked from clan/clan-core

Merge pull request 'cli' (#15) from cli into main

Reviewed-on: clan/clan-core#15
This commit is contained in:
Mic92 2023-07-21 11:31:53 +00:00
commit 8a9e7a9007
4 changed files with 17 additions and 14 deletions

View File

@ -41,7 +41,7 @@ let
propagatedBuildInputs =
dependencies
++ [ ];
passthru.tests = { inherit check; };
passthru.tests = { inherit clan-tests clan-mypy; };
passthru.devDependencies = devDependencies;
postInstall = ''
installShellCompletion --bash --name clan \
@ -53,16 +53,19 @@ let
checkPython = python3.withPackages (_ps: devDependencies ++ dependencies);
check = runCommand "${name}-check" { } ''
clan-mypy = runCommand "${name}-mypy" { } ''
cp -r ${src} ./src
chmod +w -R ./src
cd src
export PYTHONPATH=.
echo -e "\x1b[32m## run ruff\x1b[0m"
${ruff}/bin/ruff check .
echo -e "\x1b[32m## run mypy\x1b[0m"
${checkPython}/bin/mypy .
echo -e "\x1b[32m## run pytest\x1b[0m"
touch $out
'';
clan-tests = runCommand "${name}-tests" { } ''
cp -r ${src} ./src
chmod +w -R ./src
cd src
find .
${checkPython}/bin/pytest
touch $out
'';

View File

@ -7,6 +7,6 @@
in
{
packages.${name} = package;
checks.${name} = package.tests.check;
checks = package.tests;
};
}

View File

@ -1,11 +1,11 @@
import argparse
import clan_admin
from clan_cli import admin
def test_make_parser():
parser = argparse.ArgumentParser()
clan_admin.make_parser(parser)
admin.register_parser(parser)
# using fp fixture from pytest-subprocess
@ -13,5 +13,5 @@ def test_create(fp):
cmd = ["nix", "flake", "init", "-t", fp.any()]
fp.register(cmd)
args = argparse.Namespace(folder="./my-clan")
clan_admin.create(args)
admin.create(args)
assert fp.call_count(cmd) == 1

View File

@ -1,11 +1,11 @@
import sys
import clan
import clan_cli
import pytest
def test_no_args(capsys):
clan.clan()
clan_cli.main()
captured = capsys.readouterr()
assert captured.out.startswith("usage:")
@ -13,6 +13,6 @@ def test_no_args(capsys):
def test_help(capsys, monkeypatch):
monkeypatch.setattr(sys, "argv", ["", "--help"])
with pytest.raises(SystemExit):
clan.clan()
clan_cli.main()
captured = capsys.readouterr()
assert captured.out.startswith("usage:")