From 1d7d94cfb9647ba910c0b23bfa64b61c0a942a3b Mon Sep 17 00:00:00 2001 From: Lukas Pielsticker <50139597+lukaspie@users.noreply.github.com> Date: Fri, 11 Oct 2024 16:59:44 +0200 Subject: [PATCH] update entry point testing --- src/pynxtools/testing/nomad_example.py | 20 +++++++++++--------- tests/nomad/test_nomad_examples.py | 7 +++---- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/pynxtools/testing/nomad_example.py b/src/pynxtools/testing/nomad_example.py index 4bbd848fc..4cc7fc217 100644 --- a/src/pynxtools/testing/nomad_example.py +++ b/src/pynxtools/testing/nomad_example.py @@ -26,7 +26,6 @@ from nomad.config.models.plugins import ( ExampleUploadEntryPoint, - example_upload_path_prefix, ) except ImportError: pytest.skip( @@ -41,19 +40,23 @@ def get_file_parameter(example_path: str): plugin_name should be pynxtools_em, pynxtools_mpes, etc. """ - example_files = [ + example_files = ( "schema.archive.yaml", + "schema.archive.yml", + "scheme.archive.yaml", + "scheme.archive.yml", "schema.archive.json", + "scheme.archive.json", "intra-entry.archive.json", - ] - path = os.walk(os.path.join(os.path.dirname(__file__), example_path)) + ) + path = os.walk(os.path.join(os.getcwd(), example_path)) for root, _, files in path: for file in files: - if os.path.basename(file) in example_files: + if os.path.basename(file).endswith(example_files): yield pytest.param(os.path.join(root, file), id=file) -def parse_nomad_example(mainfile, no_warn): +def parse_nomad_example(mainfile): """Test if NOMAD example works.""" archive = EntryArchive() archive.m_context = Context() @@ -63,7 +66,6 @@ def parse_nomad_example(mainfile, no_warn): def example_upload_entry_point_valid(entrypoint, plugin_package, expected_local_path): """Test if NOMAD ExampleUploadEntryPoint works.""" - entrypoint.config["plugin_package"] = plugin_package + setattr(entrypoint, "plugin_package", plugin_package) entrypoint.load() - expected_local_path = f"{example_upload_path_prefix}/{expected_local_path}" - assert entry_point.local_path == expected_local_path + assert entrypoint.local_path == expected_local_path diff --git a/tests/nomad/test_nomad_examples.py b/tests/nomad/test_nomad_examples.py index d4344b97f..795ab77c0 100644 --- a/tests/nomad/test_nomad_examples.py +++ b/tests/nomad/test_nomad_examples.py @@ -38,16 +38,15 @@ @pytest.mark.parametrize( - "mainfile", get_file_parameter("../../src/pynxtools/nomad/examples/") + "mainfile", get_file_parameter("src/pynxtools/nomad/examples/") ) -def test_nomad_examples(mainfile, no_warn): +def test_nomad_examples(mainfile): """Test if NOMAD examples work.""" parse_nomad_example(mainfile) @pytest.mark.parametrize( - "entrypoint", - "expected_local_path", + ("entrypoint", "expected_local_path"), [ pytest.param( iv_temp_example,