@@ -475,3 +475,106 @@ def test_invenio_deposit(tmp_path, monkeypatch, sandbox_auth, metadata, invenio_
475475
476476 # TODO: compare to actually expected value
477477 assert result == invenio_metadata
478+
479+
480+ @pytest .mark .parametrize (
481+ "metadata_in, metadata_out" ,
482+ [
483+ (
484+ {
485+ "cff" : SoftwareMetadata ({
486+ "@type" : ["http://schema.org/SoftwareSourceCode" ],
487+ "http://schema.org/description" : [{"@value" : "for testing" }],
488+ "http://schema.org/name" : [{"@value" : "Test" }],
489+ "http://schema.org/author" : [{
490+ "@type" : "http://schema.org/Person" ,
491+ "http://schema.org/familyName" : [{"@value" : "Test" }],
492+ "http://schema.org/givenName" : [{"@value" : "Testi" }]
493+ }],
494+ "http://schema.org/license" : [{"@id" : "https://spdx.org/licenses/Apache-2.0" }]
495+ })
496+ },
497+ SoftwareMetadata ({
498+ "@type" : ["http://schema.org/SoftwareSourceCode" ],
499+ "http://schema.org/description" : [{"@value" : "for testing" }],
500+ "http://schema.org/name" : [{"@value" : "Test" }],
501+ "http://schema.org/author" : [{
502+ "@type" : "http://schema.org/Person" ,
503+ "http://schema.org/familyName" : [{"@value" : "Test" }],
504+ "http://schema.org/givenName" : [{"@value" : "Testi" }]
505+ }],
506+ "http://schema.org/license" : [{"@id" : "https://spdx.org/licenses/Apache-2.0" }]
507+ })
508+ ),
509+ (
510+ {
511+ "cff" : SoftwareMetadata ({
512+ "@type" : ["http://schema.org/SoftwareSourceCode" ],
513+ "http://schema.org/name" : [{"@value" : "Test" }],
514+ "http://schema.org/author" : [{
515+ "@type" : "http://schema.org/Person" ,
516+ "http://schema.org/familyName" : [{"@value" : "Test" }],
517+ "http://schema.org/givenName" : [{"@value" : "Testi" }],
518+ "http://schema.org/email" : [{"@value" : "test.testi@testis.tests" }]
519+ }],
520+ "http://schema.org/license" : [{"@id" : "https://spdx.org/licenses/Apache-2.0" }]
521+ }),
522+ "codemeta" : SoftwareMetadata ({
523+ "@type" : ["http://schema.org/SoftwareSourceCode" ],
524+ "http://schema.org/description" : [{"@value" : "for testing" }],
525+ "http://schema.org/name" : [{"@value" : "Test" }],
526+ "http://schema.org/author" : [{
527+ "@type" : "http://schema.org/Person" ,
528+ "http://schema.org/familyName" : [{"@value" : "Test" }],
529+ "http://schema.org/givenName" : [{"@value" : "Testi" }],
530+ "http://schema.org/email" : [{"@value" : "test.testi@testis.tests" }]
531+ }]
532+ })
533+ },
534+ SoftwareMetadata ({
535+ "@type" : ["http://schema.org/SoftwareSourceCode" ],
536+ "http://schema.org/description" : [{"@value" : "for testing" }],
537+ "http://schema.org/name" : [{"@value" : "Test" }],
538+ "http://schema.org/author" : [{
539+ "@type" : "http://schema.org/Person" ,
540+ "http://schema.org/familyName" : [{"@value" : "Test" }],
541+ "http://schema.org/givenName" : [{"@value" : "Testi" }],
542+ "http://schema.org/email" : [{"@value" : "test.testi@testis.tests" }]
543+ }],
544+ "http://schema.org/license" : [{"@id" : "https://spdx.org/licenses/Apache-2.0" }]
545+ })
546+ )
547+ ]
548+ )
549+ def test_process (tmp_path , monkeypatch , metadata_in , metadata_out ):
550+ monkeypatch .chdir (tmp_path )
551+
552+ manager = context_manager .HermesContext (tmp_path )
553+ manager .prepare_step ("harvest" )
554+ for harvester , result in metadata_in .items ():
555+ with manager [harvester ] as cache :
556+ cache ["codemeta" ] = result .compact ()
557+ cache ["context" ] = {"@context" : result .full_context }
558+ cache ["expanded" ] = result .ld_value
559+ manager .finalize_step ("harvest" )
560+
561+ config_file = tmp_path / "hermes.toml"
562+ config_file .write_text (f"[harvest]\n sources = [{ ", " .join (f"\" { harvester } \" " for harvester in metadata_in )} ]" )
563+
564+ orig_argv = sys .argv [:]
565+ sys .argv = ["hermes" , "process" , "--path" , str (tmp_path ), "--config" , str (config_file )]
566+ result = {}
567+ try :
568+ monkeypatch .setattr (context_manager .HermesContext .__init__ , "__defaults__" , (tmp_path .cwd (),))
569+ cli .main ()
570+ except SystemExit as e :
571+ if e .code != 0 :
572+ raise e
573+ finally :
574+ manager .prepare_step ("process" )
575+ result = SoftwareMetadata .load_from_cache (manager , "result" )
576+ manager .finalize_step ("process" )
577+ sys .argv = orig_argv
578+
579+ assert result .ld_value == metadata_out .ld_value
580+ assert result == metadata_out
0 commit comments