Skip to content

Commit

Permalink
Rebase after refactoring module
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianschoeppach committed May 31, 2024
1 parent bc44847 commit 77d34c7
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 8 deletions.
12 changes: 12 additions & 0 deletions tests/parsers/test_myparser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import logging

from nomad.datamodel import EntryArchive
from nomad_uibk_plugin.parsers.myparser import MyParser


def test_parse_file():
parser = MyParser()
archive = EntryArchive()
parser.parse('tests/data/example.out', archive, logging.getLogger())

assert archive.results.material.elements == ['H', 'O']
41 changes: 33 additions & 8 deletions tests/parsers/test_parser.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,37 @@
import logging
import os

from nomad.datamodel import EntryArchive
from nomad_uibk_plugin.parsers.myparser import MyParser
import pytest
from nomad.client import normalize_all, parse


def test_parse_file():
parser = MyParser()
archive = EntryArchive()
parser.parse('tests/data/example.out', archive, logging.getLogger())
@pytest.fixture(params=['QNT20220823_A1_2m.txt'])
def parsed_archive(request):
"""
Sets up a parsed archive and cleans up afterwards.
"""
file_path = os.path.join('tests', 'data', request.param)
archive_from_file = parse(file_path)[0]
measurement = os.path.join(
'tests', 'data', '.'.join(request.param.split('.')[:-1]) + '.archive.json'
)
assert archive_from_file.data.measurement.m_proxy_value == os.path.abspath(
measurement
)
measurement_archive = parse(measurement)[0]

assert archive.results.material.elements == ['H', 'O']
yield measurement_archive

if os.path.exists(measurement):
os.remove(measurement)


def test_normalize_all(parsed_archive):
"""
Tests the normalization of data in the archive.
"""
normalize_all(parsed_archive)

# checks for different parsers
if parsed_archive.data.method == 'X-Ray Fluorescence (XRF)':
# TODO: Add tests specific for XRF method
pass

0 comments on commit 77d34c7

Please sign in to comment.