1+ # SPDX-FileCopyrightText: 2026 German Aerospace Center (DLR)
2+ #
3+ # SPDX-License-Identifier: Apache-2.0
4+
5+ # SPDX-FileContributor: Michael Fritzsche
6+
17import pytest
28from hermes .commands .harvest .cff import CffHarvestPlugin , CffHarvestSettings
9+ from hermes .commands .harvest .codemeta import CodeMetaHarvestPlugin
310from hermes .model import SoftwareMetadata
411
512
1825 email: max@muster.mann""" ,
1926 SoftwareMetadata ({
2027 "@type" : "SoftwareSourceCode" ,
21- "schema: author" : {
28+ "author" : {
2229 "@list" : [{
2330 "@type" : "Person" ,
2431 "email" : ["max@muster.mann" ],
2532 "familyName" : ["Mustermann" ],
2633 "givenName" : ["Max" ]
2734 }]
2835 },
29- "schema:name" : ["Temp" ]
36+ "name" : ["Temp" ]
37+ })
38+ ),
39+ (
40+ """# SPDX-FileCopyrightText: 2022 German Aerospace Center (DLR), Helmholtz-Zentrum Dresden-Rossendorf
41+ #
42+ # SPDX-License-Identifier: CC0-1.0
43+
44+ # SPDX-FileContributor: Michael Meinel
45+
46+ cff-version: 1.2.0
47+ title: hermes
48+ message: >-
49+ If you use this software, please cite it using the
50+ metadata from this file.
51+ version: 0.9.0
52+ license: "Apache-2.0"
53+ abstract: "Tool to automate software publication. Not stable yet."
54+ type: software
55+ authors:
56+ - given-names: Michael
57+ family-names: Meinel
58+ email: michael.meinel@dlr.de
59+ affiliation: German Aerospace Center (DLR)
60+ orcid: "https://orcid.org/0000-0001-6372-3853"
61+ - given-names: Stephan
62+ family-names: Druskat
63+ email: stephan.druskat@dlr.de
64+ affiliation: German Aerospace Center (DLR)
65+ orcid: "https://orcid.org/0000-0003-4925-7248"
66+ identifiers:
67+ - type: doi
68+ value: 10.5281/zenodo.13221384
69+ description: Version 0.8.1b1
70+ """ ,
71+ SoftwareMetadata ({
72+ "@type" : ["http://schema.org/SoftwareSourceCode" ],
73+ "http://schema.org/author" : [
74+ {
75+ "@list" : [
76+ {
77+ "@id" : "https://orcid.org/0000-0001-6372-3853" ,
78+ "@type" : ["http://schema.org/Person" ],
79+ "http://schema.org/affiliation" : [
80+ {
81+ "@type" : ["http://schema.org/Organization" ],
82+ "http://schema.org/name" : [{"@value" : "German Aerospace Center (DLR)" }]
83+ }
84+ ],
85+ "http://schema.org/email" : [{"@value" : "michael.meinel@dlr.de" }],
86+ "http://schema.org/familyName" : [{"@value" : "Meinel" }],
87+ "http://schema.org/givenName" : [{"@value" : "Michael" }]
88+ },
89+ {
90+ "@id" : "https://orcid.org/0000-0003-4925-7248" ,
91+ "@type" : ["http://schema.org/Person" ],
92+ "http://schema.org/affiliation" : [
93+ {
94+ "@type" : ["http://schema.org/Organization" ],
95+ "http://schema.org/name" : [{"@value" : "German Aerospace Center (DLR)" }]
96+ }
97+ ],
98+ "http://schema.org/email" : [{"@value" : "stephan.druskat@dlr.de" }],
99+ "http://schema.org/familyName" : [{"@value" : "Druskat" }],
100+ "http://schema.org/givenName" : [{"@value" : "Stephan" }]
101+ }
102+ ]
103+ }
104+ ],
105+ "http://schema.org/description" : [{"@value" : "Tool to automate software publication. Not stable yet." }],
106+ "http://schema.org/identifier" : [{"@id" : "https://doi.org/10.5281/zenodo.13221384" }],
107+ "http://schema.org/license" : [{"@id" : "https://spdx.org/licenses/Apache-2.0" }],
108+ "http://schema.org/name" : [{"@value" : "hermes" }],
109+ "http://schema.org/version" : [{"@value" : "0.9.0" }]
30110 })
31111 )
32112 ]
@@ -51,6 +131,42 @@ def __init__(self, args, settings):
51131 cff_file .write_text (cff )
52132
53133 result = CffHarvestPlugin ().__call__ (command )
54- # FIXME: update to compare the SoftwareMetadata objects instead of the data_dicts
134+ # FIXME: update to compare the SoftwareMetadata objects instead of the data_dicts (in multiple places)
55135 # after merge with refactor/data-model and/or refactor/423-implement-public-api
56136 assert result [0 ].data_dict == res .data_dict
137+
138+
139+ @pytest .mark .parametrize (
140+ "codemeta, res" ,
141+ [
142+ (
143+ """{
144+ "@context": "https://doi.org/10.5063/schema/codemeta-2.0",
145+ "type": "SoftwareSourceCode",
146+ "description": "for testing",
147+ "name": "Test"
148+ }""" ,
149+ SoftwareMetadata ({
150+ "@type" : ["http://schema.org/SoftwareSourceCode" ],
151+ "http://schema.org/description" : [{"@value" : "for testing" }],
152+ "http://schema.org/name" : [{"@value" : "Test" }]
153+ })
154+ )
155+ ]
156+ )
157+ def test_codemeta_harvest (tmp_path , codemeta , res ):
158+ class Args :
159+ def __init__ (self , path ):
160+ self .path = path
161+
162+ class Command :
163+ def __init__ (self , args ):
164+ self .args = args
165+
166+ command = Command (Args (tmp_path ))
167+
168+ codemeta_file = tmp_path / "codemeta.json"
169+ codemeta_file .write_text (codemeta )
170+
171+ result = CodeMetaHarvestPlugin ().__call__ (command )
172+ assert result [0 ].data_dict == res .data_dict
0 commit comments