Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
nomad-FAIR
Commits
c8ea64b0
Commit
c8ea64b0
authored
Mar 20, 2020
by
Alvin Noe Ladines
Browse files
Added repo test in test_api, minor improvements
parent
231490a5
Pipeline
#71078
failed with stages
in 21 minutes and 10 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
nomad/datamodel/datamodel.py
View file @
c8ea64b0
...
...
@@ -352,7 +352,8 @@ class EntryMetadata(metainfo.MSection):
Search
(
description
=
'Search uploader with exact names.'
,
metric_name
=
'uploaders'
,
metric
=
'cardinality'
,
many_or
=
'append'
,
search_field
=
'uploader.name.keyword'
,
default_statistic
=
True
,
statistic_size
=
10
),
many_or
=
'append'
,
search_field
=
'uploader.name.keyword'
,
default_statistic
=
True
,
statistic_size
=
10
),
Search
(
name
=
'uploader_id'
,
search_field
=
'uploader.user_id'
)
])
...
...
nomad/datamodel/dft.py
View file @
c8ea64b0
...
...
@@ -112,12 +112,6 @@ def map_basis_set_to_basis_set_label(name):
return
basis_sets
.
get
(
key
,
name
)
def
map_atoms_to_compound_type
(
atoms
):
if
len
(
atoms
)
>
len
(
compound_types
):
return
'>decinary'
return
compound_types
[
len
(
atoms
)
-
1
]
def
simplify_version
(
version
):
match
=
version_re
.
search
(
version
)
if
match
is
None
:
...
...
@@ -317,7 +311,7 @@ class DFTMetadata(MSection):
atoms
=
list
(
set
(
normalized_atom_labels
(
set
(
atoms
))))
atoms
.
sort
()
entry
.
atoms
=
atoms
self
.
compound_type
=
map_atoms_to_
compound_type
(
atoms
)
self
.
compound_type
=
compound_type
s
[
len
(
atoms
)
-
1
]
if
len
(
atoms
)
<=
10
else
'>decinary'
self
.
crystal_system
=
get_optional_backend_value
(
backend
,
'crystal_system'
,
'section_symmetry'
,
logger
=
logger
)
...
...
tests/app/test_api.py
View file @
c8ea64b0
...
...
@@ -965,12 +965,19 @@ class TestRepo():
assert
'values'
in
data
[
group
]
# assert len(data[group]['values']) == data['statistics']['total']['all'][group]
def
test_search_date_histogram
(
self
,
api
,
example_elastic_calcs
,
no_warn
):
rv
=
api
.
get
(
'/repo/?date_histogram=true&metrics=dft.total_energies'
)
@
pytest
.
mark
.
parametrize
(
'query, nbuckets'
,
[
(
dict
(
interval
=
'1M'
,
metrics
=
'dft.total_energies'
),
1
),
(
dict
(
interval
=
'1d'
,
metrics
=
'dft.quantities'
),
6
),
(
dict
(
interval
=
'1y'
,
from_time
=
'2019-03-20T12:43:54.566414'
),
1
),
(
dict
(
until_time
=
'2010-03-20T12:43:54.566414'
),
0
),
(
dict
(
interval
=
'1m'
,
from_time
=
'2020-02-20T12:43:54.566414'
,
metrics
=
'dft.calculations'
),
7201
)
])
def
test_search_date_histogram
(
self
,
api
,
example_elastic_calcs
,
no_warn
,
query
,
nbuckets
):
rv
=
api
.
get
(
'/repo/?date_histogram=true&%s'
%
urlencode
(
query
))
assert
rv
.
status_code
==
200
data
=
json
.
loads
(
rv
.
data
)
histogram
=
data
.
get
(
'statistics'
).
get
(
'date_histogram'
)
assert
len
(
histogram
)
>
0
assert
len
(
histogram
)
==
nbuckets
@
pytest
.
mark
.
parametrize
(
'n_results, page, per_page'
,
[(
2
,
1
,
5
),
(
1
,
1
,
1
),
(
0
,
2
,
3
)])
def
test_search_pagination
(
self
,
api
,
example_elastic_calcs
,
no_warn
,
n_results
,
page
,
per_page
):
...
...
@@ -1033,7 +1040,10 @@ class TestRepo():
(
1
,
'atoms'
,
'Fe'
),
(
1
,
'authors'
,
'Leonard Hofstadter'
),
(
2
,
'files'
,
'test/mainfile.txt'
),
(
0
,
'dft.quantities'
,
'dos'
)
(
0
,
'dft.quantities'
,
'dos'
),
(
2
,
'dft.quantities_energy'
,
'energy_total'
),
(
2
,
'dft.compound_type'
,
'ternary'
),
(
0
,
'dft.labels_springer_compound_class'
,
'intermetallic'
)
])
def
test_quantity_search
(
self
,
api
,
example_elastic_calcs
,
no_warn
,
test_user_auth
,
calcs
,
quantity
,
value
):
rv
=
api
.
get
(
'/repo/quantity/%s'
%
quantity
,
headers
=
test_user_auth
)
...
...
Markus Scheidgen
@mscheidg
mentioned in commit
b41da687
·
Mar 25, 2020
mentioned in commit
b41da687
mentioned in commit b41da687c823568b859b0a3366ee4971dc2e1142
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment