66
77import pytest
88import sys
9- from hermes .model import context_manager , SoftwareMetadata
9+ from hermes .model import SoftwareMetadata
10+ from hermes .model .context_manager import HermesContext
1011from hermes .commands import cli
1112
1213
@@ -181,10 +182,10 @@ def test_cff_harvest(tmp_path, monkeypatch, cff, res):
181182 sys .argv = ["hermes" , "harvest" , "--path" , str (tmp_path ), "--config" , str (config_file )]
182183 result = {}
183184 try :
184- monkeypatch .setattr (context_manager . HermesContext .__init__ , "__defaults__" , (tmp_path .cwd (),))
185+ monkeypatch .setattr (HermesContext .__init__ , "__defaults__" , (tmp_path .cwd (),))
185186 cli .main ()
186187 except SystemExit :
187- manager = context_manager . HermesContext ()
188+ manager = HermesContext ()
188189 manager .prepare_step ("harvest" )
189190 with manager ["cff" ] as cache :
190191 result = SoftwareMetadata (cache ["codemeta" ])
@@ -341,10 +342,10 @@ def test_codemeta_harvest(tmp_path, monkeypatch, codemeta, res):
341342 sys .argv = ["hermes" , "harvest" , "--path" , str (tmp_path ), "--config" , str (config_file )]
342343 result = {}
343344 try :
344- monkeypatch .setattr (context_manager . HermesContext .__init__ , "__defaults__" , (tmp_path .cwd (),))
345+ monkeypatch .setattr (HermesContext .__init__ , "__defaults__" , (tmp_path .cwd (),))
345346 cli .main ()
346347 except SystemExit :
347- manager = context_manager . HermesContext ()
348+ manager = HermesContext ()
348349 manager .prepare_step ("harvest" )
349350 with manager ["codemeta" ] as cache :
350351 result = SoftwareMetadata (cache ["codemeta" ])
@@ -353,3 +354,103 @@ def test_codemeta_harvest(tmp_path, monkeypatch, codemeta, res):
353354 sys .argv = orig_argv
354355
355356 assert result .data_dict == res .data_dict
357+
358+
359+ @pytest .mark .parametrize (
360+ "process_result, res" ,
361+ [
362+ 2 * (
363+ SoftwareMetadata ({
364+ "@type" : ["http://schema.org/SoftwareSourceCode" ],
365+ "http://schema.org/description" : [{"@value" : "for testing" }],
366+ "http://schema.org/name" : [{"@value" : "Test" }]
367+ }),
368+ ),
369+ 2 * (
370+ SoftwareMetadata ({
371+ "@type" : ["http://schema.org/SoftwareSourceCode" ],
372+ "http://schema.org/applicationCategory" : [{"@id" : "Testing" }],
373+ "http://schema.org/author" : [
374+ {
375+ "@list" : [
376+ {
377+ "@id" : "_:author_1" ,
378+ "@type" : ["http://schema.org/Person" ],
379+ "http://schema.org/email" : [{"@value" : "test.testi@test.testi" }],
380+ "http://schema.org/familyName" : [{"@value" : "Testi" }],
381+ "http://schema.org/givenName" : [{"@value" : "Test" }]
382+ }
383+ ]
384+ }
385+ ],
386+ "http://schema.org/codeRepository" : [{"@id" : "https://github.com/softwarepub/hermes" }],
387+ "http://schema.org/contributor" : [
388+ {
389+ "@id" : "_:contributor_1" ,
390+ "@type" : ["http://schema.org/Person" ],
391+ "http://schema.org/email" : [{"@value" : "test.testi@test.testi" }],
392+ "http://schema.org/familyName" : [{"@value" : "Testi" }],
393+ "http://schema.org/givenName" : [{"@value" : "Test" }]
394+ }
395+ ],
396+ "http://schema.org/dateCreated" : [{"@type" : "http://schema.org/Date" , "@value" : "2026-01-16" }],
397+ "http://schema.org/dateModified" : [{"@type" : "http://schema.org/Date" , "@value" : "2026-01-16" }],
398+ "http://schema.org/datePublished" : [{"@type" : "http://schema.org/Date" , "@value" : "2026-01-16" }],
399+ "http://schema.org/description" : [{"@value" : "for testing" }],
400+ "http://schema.org/funder" : [
401+ {
402+ "@type" : ["http://schema.org/Organization" ],
403+ "http://schema.org/name" : [{"@value" : "TestsTests" }]
404+ }
405+ ],
406+ "http://schema.org/keywords" : [{"@value" : "testing" }, {"@value" : "more testing" }],
407+ "http://schema.org/license" : [
408+ {"@id" : "https://spdx.org/licenses/Adobe-2006" },
409+ {"@id" : "https://spdx.org/licenses/Abstyles" },
410+ {"@id" : "https://spdx.org/licenses/AGPL-1.0-only" }
411+ ],
412+ "http://schema.org/name" : [{"@value" : "Test" }],
413+ "http://schema.org/operatingSystem" : [{"@value" : "Windows" }],
414+ "http://schema.org/programmingLanguage" : [{"@value" : "Python" }, {"@value" : "Python 3" }],
415+ "http://schema.org/relatedLink" : [{"@id" : "https://docs.software-metadata.pub/en/latest" }],
416+ "http://schema.org/releaseNotes" : [{"@value" : "get it now" }],
417+ "http://schema.org/version" : [{"@value" : "1.1.1" }],
418+ "https://codemeta.github.io/terms/developmentStatus" : [{"@id" : "abandoned" }],
419+ "https://codemeta.github.io/terms/funding" : [{"@value" : "none :(" }],
420+ "https://codemeta.github.io/terms/isSourceCodeOf" : [{"@id" : "HERMES" }],
421+ "https://codemeta.github.io/terms/issueTracker" : [
422+ {"@id" : "https://github.com/softwarepub/hermes/issues" }
423+ ],
424+ "https://codemeta.github.io/terms/referencePublication" : [{"@id" : "https://arxiv.org/abs/2201.09015" }]
425+ }),
426+ ),
427+ ]
428+ )
429+ def test_do_nothing_curate (tmp_path , monkeypatch , process_result , res ):
430+ monkeypatch .chdir (tmp_path )
431+
432+ manager = HermesContext (tmp_path )
433+ manager .prepare_step ("process" )
434+ with manager ["result" ] as cache :
435+ cache ["expanded" ] = process_result .ld_value
436+ cache ["context" ] = {"@context" : process_result .full_context }
437+ manager .finalize_step ("process" )
438+
439+ config_file = tmp_path / "hermes.toml"
440+ config_file .write_text ("" )
441+
442+ orig_argv = sys .argv [:]
443+ sys .argv = ["hermes" , "curate" , "--path" , str (tmp_path ), "--config" , str (config_file )]
444+ result = {}
445+ try :
446+ monkeypatch .setattr (HermesContext .__init__ , "__defaults__" , (tmp_path .cwd (),))
447+ cli .main ()
448+ except SystemExit :
449+ manager .prepare_step ("curate" )
450+ with manager ["result" ] as cache :
451+ result = SoftwareMetadata (cache ["expanded" ][0 ], cache ["context" ]["@context" ][1 ])
452+ manager .finalize_step ("curate" )
453+ finally :
454+ sys .argv = orig_argv
455+
456+ assert result .data_dict == res .data_dict
0 commit comments