generated from FAIRmat-NFDI/nomad-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc44847
commit 77d34c7
Showing
2 changed files
with
45 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |