Skip to content

Commit

Permalink
update entry point testing
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaspie committed Oct 11, 2024
1 parent a50cf7b commit 1d7d94c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
20 changes: 11 additions & 9 deletions src/pynxtools/testing/nomad_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

from nomad.config.models.plugins import (
ExampleUploadEntryPoint,
example_upload_path_prefix,
)
except ImportError:
pytest.skip(
Expand All @@ -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()
Expand All @@ -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
7 changes: 3 additions & 4 deletions tests/nomad/test_nomad_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1d7d94c

Please sign in to comment.