From 408650f29e64190d215db059f57aa71041bf0f26 Mon Sep 17 00:00:00 2001 From: Lukas Pielsticker <50139597+lukaspie@users.noreply.github.com> Date: Wed, 27 Nov 2024 00:44:25 +0100 Subject: [PATCH] simplify test for nomad ExampleUploadEntryPoint --- src/pynxtools/testing/nomad_example.py | 9 +++++++-- tests/nomad/test_nomad_examples.py | 8 +------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/pynxtools/testing/nomad_example.py b/src/pynxtools/testing/nomad_example.py index c2d11e95d..ff2d7d160 100644 --- a/src/pynxtools/testing/nomad_example.py +++ b/src/pynxtools/testing/nomad_example.py @@ -92,16 +92,21 @@ def parse_nomad_examples(mainfile: str) -> Dict[str, Any]: def example_upload_entry_point_valid( - entrypoint: ExampleUploadEntryPoint, expected_upload_files: List[str] + entrypoint: ExampleUploadEntryPoint, example_path: str ) -> None: """ Test if NOMAD ExampleUploadEntryPoint works. Args: entrypoint (nomad.config.models.plugins.ExampleUploadEntryPoint): The entry point to test. - expected_upload_files List[str]: List of expected uploaded files. + expected_upload_files (str): String path of the example. """ + expected_upload_files = [] + for dirpath, dirnames, filenames in os.walk(example_path): + for filename in filenames: + file_path = os.path.relpath(os.path.join(dirpath, filename), example_path) + expected_upload_files.append(file_path) with tempfile.TemporaryDirectory() as tmp_upload_directory: entrypoint.load(tmp_upload_directory) diff --git a/tests/nomad/test_nomad_examples.py b/tests/nomad/test_nomad_examples.py index e66355823..9d86c0330 100644 --- a/tests/nomad/test_nomad_examples.py +++ b/tests/nomad/test_nomad_examples.py @@ -69,13 +69,7 @@ def test_parse_nomad_examples(mainfile): ) def test_example_upload_entry_point_valid(entrypoint, example_path): """Test if NOMAD ExampleUploadEntryPoint works.""" - expected_upload_files = [] - for dirpath, dirnames, filenames in os.walk(example_path): - for filename in filenames: - file_path = os.path.relpath(os.path.join(dirpath, filename), example_path) - expected_upload_files.append(file_path) - example_upload_entry_point_valid( entrypoint=entrypoint, - expected_upload_files=expected_upload_files, + example_path=example_path, )