1de0439e2d
* new file: docker/Dockerfile Dockerfile for pygeoapi * modified: pygeoapi/provider/__init__.py new file: tests/data/ne_110m_lakes.sqlite new file: tests/json_marshmallow.py new file: tests/test_sqlite_provider.py Sqlit implementation and testing marshmallows * new file: provider/sqlite.py new file: provider/tmp_parser.py Sqlite provider * Testing sqlalchemy * query for sqlite3 * Countries dataset, message in assert * yml config * table in data link and query implemented without limit * PR of refactor * functional sqlite3 driver * flake8 * pipreq for complete list of requirements * updated readme with working examples, extra requirements * typos, SQLite removed Dockerfile and ne_100m_lakes.sqlite * update requirements * pypandoc in requirements-dev.txt
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
# 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']
|