diff --git a/= b/= new file mode 100644 index 0000000000000000000000000000000000000000..9b92bcf0f4abca1d5e13a468e25623bd7986bdb2 --- /dev/null +++ b/= @@ -0,0 +1,7 @@ +============================= test session starts ============================== +platform darwin -- Python 3.7.7, pytest-3.10.0, py-1.10.0, pluggy-0.13.1 -- /Users/markus/Documents/Projects/nomad-fairdi/.pyenv/bin/python +cachedir: .pytest_cache +rootdir: /Users/markus/Documents/Projects/nomad-fairdi/tests, inifile: pytest.ini +plugins: celery-4.4.7, cov-2.7.1, timeout-1.4.2 +collecting ... +========================= no tests ran in 0.01 seconds ========================= diff --git a/nomad/app/optimade/filterparser.py b/nomad/app/optimade/filterparser.py index f233403361f5c1e44c3917fa0f8496be7cfa5b68..2cab798bd620d5b17be2408a66e594cb483084b6 100644 --- a/nomad/app/optimade/filterparser.py +++ b/nomad/app/optimade/filterparser.py @@ -17,7 +17,7 @@ # from typing import Dict -from elasticsearch_dsl import Q +from elasticsearch_dsl import Q, Date from cachetools import cached from optimade.filterparser import LarkParser @@ -49,6 +49,8 @@ def _get_transformer(nomad_properties, without_prefix): quantities['id'] = Quantity('id', es_field='calc_id') quantities['immutable_id'] = Quantity('immutable_id', es_field='calc_id') + quantities['last_modified'] = Quantity( + 'last_modified', es_field='upload_time', elastic_mapping_type=Date) quantities['elements'].length_quantity = quantities['nelements'] quantities['elements'].has_only_quantity = Quantity(name='only_atoms') diff --git a/nomad/datamodel/optimade.py b/nomad/datamodel/optimade.py index b617069a145b0070ca079f96dba3f80cc189b0b2..b42b5e0b9a7baf9127d34b515cbca518b8bf5148 100644 --- a/nomad/datamodel/optimade.py +++ b/nomad/datamodel/optimade.py @@ -240,6 +240,7 @@ class OptimadeEntry(MSection): species_at_sites = Quantity( type=str, shape=['nsites'], links=optimade_links('h.6.2.12'), + a_search=Search(), a_optimade=Optimade(query=False, entry=True, sortable=False, type='list'), description=''' Name of the species at each site (where values for sites are specified with the same order of the cartesian_site_positions property). The properties of the species are diff --git a/tests/app/flask/utils.py b/tests/app/flask/utils.py index 3e20e664ef31638622cb91faf1db2bd08d22b7fa..02268e90f3ec224c7d37c1e4922510c44e8b5161 100644 --- a/tests/app/flask/utils.py +++ b/tests/app/flask/utils.py @@ -18,6 +18,7 @@ from typing import List import numpy as np +import datetime from nomad import processing, files from nomad.datamodel import EntryMetadata, MongoMetadata, EntryArchive @@ -102,7 +103,8 @@ class Upload(): entry_metadata.m_update( domain='dft', upload_id=self.upload_id, calc_id='test_calc_id_%d' % id, - mainfile='test_mainfile', published=True, processed=True, with_embargo=False) + mainfile='test_mainfile', published=True, processed=True, with_embargo=False, + upload_time=datetime.datetime.now()) entry_metadata.apply_domain_metadata(archive) diff --git a/tests/app/test_optimade.py b/tests/app/test_optimade.py index 77eea728dfb62afe1a3e204f1d35a9f3cad9e1e7..b684da761e52964e212c0580d59d637da434de3b 100644 --- a/tests/app/test_optimade.py +++ b/tests/app/test_optimade.py @@ -60,7 +60,7 @@ def example_structures(elastic_infra, mongo_infra, raw_files_infra): upload.create_test_structure(1, 2, 1, [], 0) upload.create_test_structure(2, 2, 1, ['C'], 0) upload.create_test_structure(3, 2, 1, [], 1) - upload.create_test_structure(4, 1, 1, [], 0) + upload.create_test_structure(4, 1, 1, [], 0, metadata=dict(upload_time='1978-04-08T10:10:00Z')) upload.create_upload_files() search.refresh() @@ -126,7 +126,9 @@ def example_structures(elastic_infra, mongo_infra, raw_files_infra): ('nelements LENGTH = 1', -1), ('LENGTH nelements = 1', -1), ('chemical_formula_anonymous starts with "A"', -1), - ('elements HAS ONY "H", "O"', -1) + ('elements HAS ONY "H", "O"', -1), + ('last_modified >= "2009-02-01T20:07:00Z"', 3), + ('species_at_sites HAS "C"', 1) ]) def test_optimade_parser(example_structures, query, results): if results >= 0: