68 lines
2.4 KiB
Python
68 lines
2.4 KiB
Python
# =================================================================
|
|
#
|
|
# Authors: Just van den Broecke <justb4@gmail.com>
|
|
#
|
|
# Copyright (c) 2019 Just van den Broecke
|
|
#
|
|
# Permission is hereby granted, free of charge, to any person
|
|
# obtaining a copy of this software and associated documentation
|
|
# files (the "Software"), to deal in the Software without
|
|
# restriction, including without limitation the rights to use,
|
|
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
# copies of the Software, and to permit persons to whom the
|
|
# Software is furnished to do so, subject to the following
|
|
# conditions:
|
|
#
|
|
# The above copyright notice and this permission notice shall be
|
|
# included in all copies or substantial portions of the Software.
|
|
#
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
# OTHER DEALINGS IN THE SOFTWARE.
|
|
#
|
|
# =================================================================
|
|
|
|
# Needs to be run like: pytest -s test_sqlite_provider.py
|
|
# In eclipse we need to set PYGEOAPI_CONFIG, Run>Debug Configurations>
|
|
# (Arguments as py.test and set external variables to the correct config path)
|
|
|
|
import pytest
|
|
from pygeoapi.provider.sqlite import SQLiteProvider
|
|
|
|
|
|
@pytest.fixture()
|
|
def config():
|
|
return {
|
|
'name': 'Sqlite',
|
|
'data': './tests/data/ne_110m_admin_0_countries.sqlite',
|
|
'id_field': "ogc_fid",
|
|
'table': 'ne_110m_admin_0_countries'
|
|
}
|
|
|
|
|
|
def test_query(config):
|
|
"""Testing query for a valid JSON object with geometry"""
|
|
|
|
p = SQLiteProvider(config)
|
|
feature_collection = p.query()
|
|
assert feature_collection.get('type', None) == "FeatureCollection"
|
|
features = feature_collection.get('features', None)
|
|
assert features is not None
|
|
feature = features[0]
|
|
properties = feature.get("properties", None)
|
|
assert properties is not None
|
|
geometry = feature.get("geometry", None)
|
|
assert geometry is not None
|
|
|
|
|
|
def test_get(config):
|
|
p = SQLiteProvider(config)
|
|
results = p.get(118)
|
|
assert len(results['features']) == 1
|
|
assert "Netherlands" in results['features'][0]['properties']['admin']
|