Skip to content

Commit

Permalink
simplify test for nomad ExampleUploadEntryPoint
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaspie committed Nov 26, 2024
1 parent cc1dd6d commit 408650f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
9 changes: 7 additions & 2 deletions src/pynxtools/testing/nomad_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 1 addition & 7 deletions tests/nomad/test_nomad_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

0 comments on commit 408650f

Please sign in to comment.