Skip to content

Commit

Permalink
add integration tests for nomad example entrypoints
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaspie committed Oct 14, 2024
1 parent 886e4ba commit d4bad5f
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions tests/test_nomad_examples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#
# Copyright The NOMAD Authors.
#
# This file is part of NOMAD. See https://nomad-lab.eu for further info.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""Test for NOMAD examples in APM reader plugin."""

import pytest

try:
from nomad.parsing.parser import ArchiveParser
from nomad.datamodel import EntryArchive, Context
except ImportError:
pytest.skip(
"Skipping NOMAD example tests because nomad is not installed",
allow_module_level=True,
)

from pynxtools.testing.nomad_example import (
get_file_parameter,
parse_nomad_examples,
example_upload_entry_point_valid,
)

from pynxtools_apm.nomad.entrypoints import apm_example


@pytest.mark.parametrize(
"mainfile", get_file_parameter("src/pynxtools_apm/nomad/examples")
)
def test_parse_nomad_examples(mainfile):
"""Test if NOMAD examples work."""
parse_nomad_examples(mainfile)


@pytest.mark.parametrize(
("entrypoint", "expected_local_path"),
[
pytest.param(
apm_example,
"examples/data/uploads/apm.zip",
id="apm_example",
),
],
)
def test_nomad_example_upload_entry_point_valid(entrypoint, expected_local_path):
"""Test if NOMAD ExampleUploadEntryPoint works."""
example_upload_entry_point_valid(
entrypoint=entrypoint,
plugin_package="pynxtools-apm",
expected_local_path=expected_local_path,

0 comments on commit d4bad5f

Please sign in to comment.