Skip to content

Commit 89191ec

Browse files
committed
Imporve first cli harvest tests
1 parent 65399be commit 89191ec

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

test/hermes_test/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def __enter__(self):
3434

3535
def run(self, *args):
3636
proc = subprocess.Popen(
37-
[sys.executable, "-m", self.hermes_exe, *args], stdout=subprocess.PIPE, stderr=subprocess.PIPE
37+
[sys.executable, "-m", self.hermes_exe, *args], bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE
3838
)
3939
proc.wait()
4040
return proc

test/hermes_test/test_cli.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
# flake8: noqa
88

99
import pytest
10+
import os
1011

1112
from hermes.commands import cli
13+
from hermes import error
1214

1315

1416
def test_hermes_full():
@@ -18,7 +20,7 @@ def test_hermes_full():
1820

1921

2022
def test_hermes_harvest(hermes_env):
21-
hermes_env['hermes.toml'] = "[harvest]\nsources = [\"cff\"]\n"
23+
hermes_env['hermes.toml'] = "[harvest]\nsources = [\"cff\", \"foo\"]\n"
2224
hermes_env['CITATION.cff'] = """cff-version: 1.2.0
2325
title: Test
2426
message: >-
@@ -29,8 +31,32 @@ def test_hermes_harvest(hermes_env):
2931

3032
with hermes_env:
3133
result = hermes_env.run("harvest")
34+
stdout_res = result.stdout.read().decode()
3235

36+
test_dir = hermes_env.test_path
37+
assert len(os.listdir(test_dir)) == 4
38+
log = test_dir / "hermes.log"
39+
#print(log.read_text())
40+
assert log.exists()
41+
assert len(os.listdir(test_dir/ ".hermes/harvest/cff/")) == 3
42+
output_file = test_dir / ".hermes/harvest/cff/codemeta.json"
43+
assert output_file.exists()
3344
assert result.returncode == 0
45+
assert "Run cff plugin" in stdout_res
46+
assert "Plugin foo not found" in stdout_res
47+
48+
49+
@pytest.mark.dev
50+
def test_hermes_harvest_no_plugin(hermes_env):
51+
hermes_env['hermes.toml'] = "[harvest]\nsources = []\n"
52+
with hermes_env:
53+
result = hermes_env.run("harvest")
54+
stdout_res = result.stdout.read().decode()
55+
test_dir = hermes_env.test_path
56+
log = test_dir / "hermes.log"
57+
58+
assert result.returncode == 1
59+
assert "hermes.error.MisconfigurationError: No harvest plugin was configured to be run and loaded." in stdout_res
3460

3561

3662
def test_hermes_process(hermes_env):

0 commit comments

Comments
 (0)