Skip to content

Commit dd425ee

Browse files
committed
add tests
1 parent 9dcda0a commit dd425ee

3 files changed

Lines changed: 30 additions & 3 deletions

File tree

tests/functionaltests/suites/oarec/conftest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ def config():
111111
},
112112
'repository': {
113113
'database': 'sqlite:///tests/functionaltests/suites/cite/data/cite.db', # noqa
114-
'table': 'records'
114+
'table': 'records',
115+
'facets': [
116+
'type'
117+
]
115118
}
116119
}
117120

tests/functionaltests/suites/oarec/test_oarec_functional.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def test_conformance(config):
7777
content = json.loads(content)
7878

7979
assert headers['Content-Type'] == 'application/json'
80-
assert len(content['conformsTo']) == 14
80+
assert len(content['conformsTo']) == 16
8181

8282

8383
def test_collections(config):
@@ -113,10 +113,34 @@ def test_queryables(config):
113113
assert 'geometry' in content['properties']
114114
assert content['properties']['geometry']['$ref'] == 'https://geojson.org/schema/Polygon.json' # noqa
115115

116+
assert content['properties']['type']['facet'] # test is truthy
117+
116118
headers, status, content = api.queryables({}, {}, collection='foo')
117119
assert status == 400
118120

119121

122+
def test_facets(config):
123+
api = API(config)
124+
headers, status, content = api.facets_({}, {})
125+
content = json.loads(content)
126+
127+
assert headers['Content-Type'] == 'application/facets+json'
128+
assert content['type'] == 'object'
129+
assert content['title'] == 'pycsw Geospatial Catalogue'
130+
assert content['$id'] == 'http://localhost/pycsw/oarec/collections/metadata:main/facets' # noqa
131+
assert content['$schema'] == 'http://json-schema.org/draft/2019-09/schema'
132+
133+
assert len(content['facets']) == 1
134+
135+
assert 'type' in content['facets']
136+
assert content['facets']['type']['type'] == 'term'
137+
assert content['facets']['type']['property'] == 'type'
138+
assert content['facets']['type']['sortedBy'] == 'count'
139+
140+
headers, status, content = api.facets_({}, {}, collection='foo')
141+
assert status == 400
142+
143+
120144
def test_items(config):
121145
api = API(config)
122146
headers, status, content = api.items({}, None, {})

tests/functionaltests/suites/oarec/test_oarec_virtual_collections_functional.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def test_conformance(config_virtual_collections):
7373
api = API(config_virtual_collections)
7474
content = json.loads(api.conformance({}, {})[2])
7575

76-
assert len(content['conformsTo']) == 14
76+
assert len(content['conformsTo']) == 16
7777

7878

7979
def test_collections(config_virtual_collections):

0 commit comments

Comments
 (0)