Skip to content

Commit

Permalink
Adding test to ensure float-range is understood as numeric-range
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill888 authored and mergify[bot] committed Aug 15, 2018
1 parent bdcccc2 commit 38313df
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions datacube/model/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def parse_search_field(doc, name=''):

if raw_type == 'float': # float-range is supposed to be supported, but not just float?
raw_type = 'numeric'
_type = 'numeric-range'

if raw_type not in parsers:
raise ValueError('Unsupported search field type: ' + str(_type))
Expand Down
9 changes: 9 additions & 0 deletions tests/test_metadata_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@
min_offset: [[x,a], [x,b], [x,c], [x,d]]
max_offset: [[x,a], [x,b], [x,c], [x,d]]
float_range:
type: float-range
description: float-range is alias for numeric-range
min_offset: [[a]]
max_offset: [[b]]
ab:
type: integer-range
min_offset: [[a]]
Expand Down Expand Up @@ -134,6 +140,9 @@ def test_get_dataset_range_fields():
assert xx['ab'].extract(dict(a=3)) == Range(3, None)
assert xx['ab'].extract(dict(b=4)) == Range(None, 4)

# float-range conversion
assert xx['float_range'].type_name == 'numeric-range'


def test_metadata_from_doc():
mm = metadata_from_doc(METADATA_DOC)
Expand Down

0 comments on commit 38313df

Please sign in to comment.