Skip to content

Commit

Permalink
Fixed tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
lauri-codes committed Jun 5, 2024
1 parent fcd7c5c commit 8e71217
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/nomad_tadf_molecules/apps/tadf_molecules.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
'material': FilterMenu(label='Material'),
'elements': FilterMenu(label='Elements / Formula', level=1, size='xl'),
'custom_quantities': FilterMenu(label='Custom Quantities', size='l'),
'metadata': FilterMenu(label='Visibility / IDs / Schema'),
}
),
dashboard=Dashboard(
Expand Down
5 changes: 2 additions & 3 deletions tests/apps/test_app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
def test_importing_app():
# this will raise an exception if pydantic model validation fails for th app
from nomad_tadf_molecules.apps import myapp

# This will raise an exception if pydantic model validation fails for the app
from nomad_tadf_molecules.apps import tadf_molecules # noqa: F401
Empty file removed tests/data/example.out
Empty file.
1 change: 1 addition & 0 deletions tests/data/molecule30.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"smiles":"C=Cc1ccc(COc2ccc(C(C)(C)c3ccc(O)cc3)cc2)cc1","doi":"https:\/\/doi.org\/10.1039\/D1TC05010A","compound_names":"[\"4-(2-(4-((4-Vinylbenzyl)oxy)phenyl)propan-2-yl)phenol\",\"4-(2-(4-((4-vinylbenzyl)oxy)phenyl)propan-2-yl)phenol\",\"Bisphenol A\",\"P4CzCN\u2013BCz\"]","phase":"{\"specifier\":\"solution\",\"host\":\"toluene\"}","photoluminescence_quantum_yield_value":null,"photoluminescence_quantum_yield_unit":null,"delayed_lifetime_value":null,"delayed_lifetime_unit":null,"peak_emission_wavelength_value":493.0,"peak_emission_wavelength_unit":"nm","singlet_triplet_energy_splitting_value":0.17,"singlet_triplet_energy_splitting_unit":"eV","host":"toluene","specifier":"solution","iupac_name":"4-(2-(4-((4-Vinylbenzyl)oxy)phenyl)propan-2-yl)phenol","abbreviated_name":"4-(2-(4-((4-vinylbenzyl)oxy)phenyl)propan-2-yl)phenol"}
7 changes: 5 additions & 2 deletions tests/data/test.archive.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
data:
m_def: nomad_tadf_molecules.schema_packages.mypackage.MySchema
name: Markus
m_def: nomad_tadf_molecules.schema_packages.tadf_molecules.TADFMolecule
photoluminescence_quantum_yield: 0.1
peak_emission_wavelength: 400
delayed_lifetime: 3
singlet_triplet_energy_splitting: 2
8 changes: 3 additions & 5 deletions tests/parsers/test_parser.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import logging

from nomad.datamodel import EntryArchive
from nomad_tadf_molecules.parsers.myparser import MyParser
from nomad_tadf_molecules.parsers.tadf_molecules import TADFMoleculesParser


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

assert archive.results.material.elements == ['H', 'O']
parser.parse('tests/data/molecule30.json', archive, logging.getLogger())
8 changes: 6 additions & 2 deletions tests/schema_packages/test_schema.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# ruff: noqa: PLR2004
import os.path

from nomad.client import normalize_all, parse


def test_schema():
def test_tadf_schema():
test_file = os.path.join('tests', 'data', 'test.archive.yaml')
entry_archive = parse(test_file)[0]
normalize_all(entry_archive)

assert entry_archive.data.message == 'Hello Markus!'
assert entry_archive.data.photoluminescence_quantum_yield == 0.1
assert entry_archive.data.peak_emission_wavelength.magnitude == 400
assert entry_archive.data.delayed_lifetime.magnitude == 3
assert entry_archive.data.singlet_triplet_energy_splitting.magnitude == 2

0 comments on commit 8e71217

Please sign in to comment.