|
| 1 | +# SPDX-FileCopyrightText: 2026 German Aerospace Center (DLR) |
| 2 | +# |
| 3 | +# SPDX-License-Identifier: Apache-2.0 |
| 4 | + |
| 5 | +# SPDX-FileContributor: Michael Fritzsche |
| 6 | + |
| 7 | +import sys |
| 8 | + |
| 9 | +import pytest |
| 10 | + |
| 11 | +from hermes.commands import cli |
| 12 | +from hermes.model import context_manager, SoftwareMetadata |
| 13 | + |
| 14 | + |
| 15 | +@pytest.mark.parametrize( |
| 16 | + "process_result, res", |
| 17 | + [ |
| 18 | + 2 * ( |
| 19 | + SoftwareMetadata({ |
| 20 | + "@type": ["http://schema.org/SoftwareSourceCode"], |
| 21 | + "http://schema.org/description": [{"@value": "for testing"}], |
| 22 | + "http://schema.org/name": [{"@value": "Test"}] |
| 23 | + }), |
| 24 | + ), |
| 25 | + 2 * ( |
| 26 | + SoftwareMetadata({ |
| 27 | + "@type": ["http://schema.org/SoftwareSourceCode"], |
| 28 | + "http://schema.org/applicationCategory": [{"@id": "Testing"}], |
| 29 | + "http://schema.org/author": [ |
| 30 | + { |
| 31 | + "@list": [ |
| 32 | + { |
| 33 | + "@id": "_:author_1", |
| 34 | + "@type": ["http://schema.org/Person"], |
| 35 | + "http://schema.org/email": [{"@value": "test.testi@test.testi"}], |
| 36 | + "http://schema.org/familyName": [{"@value": "Testi"}], |
| 37 | + "http://schema.org/givenName": [{"@value": "Test"}] |
| 38 | + } |
| 39 | + ] |
| 40 | + } |
| 41 | + ], |
| 42 | + "http://schema.org/codeRepository": [{"@id": "https://github.com/softwarepub/hermes"}], |
| 43 | + "http://schema.org/contributor": [ |
| 44 | + { |
| 45 | + "@id": "_:contributor_1", |
| 46 | + "@type": ["http://schema.org/Person"], |
| 47 | + "http://schema.org/email": [{"@value": "test.testi@test.testi"}], |
| 48 | + "http://schema.org/familyName": [{"@value": "Testi"}], |
| 49 | + "http://schema.org/givenName": [{"@value": "Test"}] |
| 50 | + } |
| 51 | + ], |
| 52 | + "http://schema.org/dateCreated": [{"@type": "http://schema.org/Date", "@value": "2026-01-16"}], |
| 53 | + "http://schema.org/dateModified": [{"@type": "http://schema.org/Date", "@value": "2026-01-16"}], |
| 54 | + "http://schema.org/datePublished": [{"@type": "http://schema.org/Date", "@value": "2026-01-16"}], |
| 55 | + "http://schema.org/description": [{"@value": "for testing"}], |
| 56 | + "http://schema.org/funder": [ |
| 57 | + { |
| 58 | + "@type": ["http://schema.org/Organization"], |
| 59 | + "http://schema.org/name": [{"@value": "TestsTests"}] |
| 60 | + } |
| 61 | + ], |
| 62 | + "http://schema.org/keywords": [{"@value": "testing"}, {"@value": "more testing"}], |
| 63 | + "http://schema.org/license": [ |
| 64 | + {"@id": "https://spdx.org/licenses/Adobe-2006"}, |
| 65 | + {"@id": "https://spdx.org/licenses/Abstyles"}, |
| 66 | + {"@id": "https://spdx.org/licenses/AGPL-1.0-only"} |
| 67 | + ], |
| 68 | + "http://schema.org/name": [{"@value": "Test"}], |
| 69 | + "http://schema.org/operatingSystem": [{"@value": "Windows"}], |
| 70 | + "http://schema.org/programmingLanguage": [{"@value": "Python"}, {"@value": "Python 3"}], |
| 71 | + "http://schema.org/relatedLink": [{"@id": "https://docs.software-metadata.pub/en/latest"}], |
| 72 | + "http://schema.org/releaseNotes": [{"@value": "get it now"}], |
| 73 | + "http://schema.org/version": [{"@value": "1.1.1"}], |
| 74 | + "https://codemeta.github.io/terms/developmentStatus": [{"@id": "abandoned"}], |
| 75 | + "https://codemeta.github.io/terms/funding": [{"@value": "none :("}], |
| 76 | + "https://codemeta.github.io/terms/isSourceCodeOf": [{"@id": "HERMES"}], |
| 77 | + "https://codemeta.github.io/terms/issueTracker": [ |
| 78 | + {"@id": "https://github.com/softwarepub/hermes/issues"} |
| 79 | + ], |
| 80 | + "https://codemeta.github.io/terms/referencePublication": [{"@id": "https://arxiv.org/abs/2201.09015"}] |
| 81 | + }), |
| 82 | + ), |
| 83 | + ] |
| 84 | +) |
| 85 | +def test_do_nothing_curate(tmp_path, monkeypatch, process_result, res): |
| 86 | + monkeypatch.chdir(tmp_path) |
| 87 | + |
| 88 | + manager = context_manager.HermesContext(tmp_path) |
| 89 | + manager.prepare_step("process") |
| 90 | + with manager["result"] as cache: |
| 91 | + cache["expanded"] = process_result.ld_value |
| 92 | + cache["context"] = {"@context": process_result.full_context} |
| 93 | + manager.finalize_step("process") |
| 94 | + |
| 95 | + config_file = tmp_path / "hermes.toml" |
| 96 | + config_file.write_text("") |
| 97 | + |
| 98 | + orig_argv = sys.argv[:] |
| 99 | + sys.argv = ["hermes", "curate", "--path", str(tmp_path), "--config", str(config_file)] |
| 100 | + result = {} |
| 101 | + try: |
| 102 | + monkeypatch.setattr(context_manager.HermesContext.__init__, "__defaults__", (tmp_path.cwd(),)) |
| 103 | + cli.main() |
| 104 | + except SystemExit as e: |
| 105 | + if e.code != 0: |
| 106 | + raise e |
| 107 | + finally: |
| 108 | + manager.prepare_step("curate") |
| 109 | + result = SoftwareMetadata.load_from_cache(manager, "result") |
| 110 | + manager.finalize_step("curate") |
| 111 | + sys.argv = orig_argv |
| 112 | + |
| 113 | + assert result.data_dict == res.data_dict |
0 commit comments