77# flake8: noqa
88
99import pytest
10+ import os
1011
1112from hermes .commands import cli
13+ from hermes import error
1214
1315
1416def test_hermes_full ():
@@ -18,7 +20,7 @@ def test_hermes_full():
1820
1921
2022def test_hermes_harvest (hermes_env ):
21- hermes_env ['hermes.toml' ] = "[harvest]\n sources = [\" cff\" ]\n "
23+ hermes_env ['hermes.toml' ] = "[harvest]\n sources = [\" cff\" , \" foo \" ]\n "
2224 hermes_env ['CITATION.cff' ] = """cff-version: 1.2.0
2325title: Test
2426message: >-
@@ -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]\n sources = []\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
3662def test_hermes_process (hermes_env ):
0 commit comments