Skip to content

Commit

Permalink
barebone for verify test, extract nomad parse test
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaspie committed Sep 12, 2024
1 parent 9c7fb87 commit 0f7ccd1
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions src/pynxtools/testing/nexus_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from glob import glob
from typing import Literal

# from click.testing import CliRunner

try:
from nomad.client import parse

Expand Down Expand Up @@ -127,16 +129,13 @@ def convert_to_nexus(

Writer(read_data, nxdl_file, self.created_nexus).write()

if NOMAD_AVAILABLE:
kwargs = dict(
strict=True,
parser_name=None,
server_context=False,
username=None,
password=None,
)

parse(self.created_nexus, **kwargs)
# This shall be reactivated once verify_nexus works!
# # def test_verify_nexus(
# self,
# caplog_level: Literal["ERROR", "WARNING"] = "ERROR",
# ):
# with self.caplog.at_level(caplog_level):
# _ = CliRunner().invoke(verify, [str(self.created_nexus)])

def check_reproducibility_of_nexus(self):
"""Reproducibility test for the generated nexus file."""
Expand All @@ -163,3 +162,16 @@ def check_reproducibility_of_nexus(self):
f"Log files are different at line {ind}"
f" generated: {gen_l} \n referenced : {ref_l}"
)

def test_parse_nomad(self):
"""Check if the generated nexus file can be parse by NOMAD."""
if NOMAD_AVAILABLE:
kwargs = dict(
strict=True,
parser_name=None,
server_context=False,
username=None,
password=None,
)

parse(self.created_nexus, **kwargs)

0 comments on commit 0f7ccd1

Please sign in to comment.