Commit 5bee735e authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Added support for latest optimade features.

parent 3703f744
Pipeline #99792 passed with stages
in 25 minutes
============================= 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 =========================
......@@ -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')
......
......@@ -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
......
......@@ -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)
......
......@@ -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:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment