Skip to content

Commit

Permalink
Improved parser test.
Browse files Browse the repository at this point in the history
  • Loading branch information
lauri-codes committed Jun 5, 2024
1 parent 8e71217 commit f1f8f74
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
19 changes: 18 additions & 1 deletion tests/data/molecule30.json
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
{"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"}
{
"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: 7 additions & 0 deletions tests/parsers/test_parser.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# ruff: noqa: PLR2004
import logging

from nomad.datamodel import EntryArchive

from nomad_tadf_molecules.parsers.tadf_molecules import TADFMoleculesParser


def test_parse_file():
parser = TADFMoleculesParser()
archive = EntryArchive()
parser.parse('tests/data/molecule30.json', archive, logging.getLogger())

assert archive.data.photoluminescence_quantum_yield is None
assert archive.data.peak_emission_wavelength.magnitude == 493.0
assert archive.data.delayed_lifetime is None
assert archive.data.singlet_triplet_energy_splitting.magnitude == 0.17
12 changes: 6 additions & 6 deletions tests/schema_packages/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

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

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
assert archive.data.photoluminescence_quantum_yield == 0.1
assert archive.data.peak_emission_wavelength.magnitude == 400
assert archive.data.delayed_lifetime.magnitude == 3
assert archive.data.singlet_triplet_energy_splitting.magnitude == 2

0 comments on commit f1f8f74

Please sign in to comment.