コード例 #1
0
def test_query_with_property_filter_bbox_sqlite_geopackage(config_sqlite):
    """Test query  valid features when filtering by property"""
    p = SQLiteGPKGProvider(config_sqlite)
    feature_collection = p.query(properties=[("continent", "Europe")],
                                 bbox=[29.3373, -3.4099, 29.3761, -3.3924])
    features = feature_collection.get('features', None)
    assert len(features) == 0
コード例 #2
0
def test_get_geopackage_skip_geometry(config_geopackage):
    """Testing query for skipped geometry"""
    p = SQLiteGPKGProvider(config_geopackage)

    feature_collection = p.query(skip_geometry=True)
    for feature in feature_collection['features']:
        assert feature['geomtry'] is None
コード例 #3
0
def test_get_geopackage(config_geopackage):
    p = SQLiteGPKGProvider(config_geopackage)
    result = p.get(536678593)
    assert isinstance(result, dict)
    assert 'geometry' in result
    assert 'properties' in result
    assert 'id' in result
    assert 'Académico' in result['properties']['name']
コード例 #4
0
def test_get_sqlite(config_sqlite):
    p = SQLiteGPKGProvider(config_sqlite)
    result = p.get(118)
    assert isinstance(result, dict)
    assert 'geometry' in result
    assert 'properties' in result
    assert 'id' in result
    assert 'Netherlands' in result['properties']['admin']
コード例 #5
0
def test_query_with_property_filter_sqlite_geopackage(config_sqlite):
    """Test query  valid features when filtering by property"""

    p = SQLiteGPKGProvider(config_sqlite)
    feature_collection = p.query(properties=[("continent", "Europe")],
                                 limit=100)
    features = feature_collection.get('features', None)
    assert len(features) == 39
コード例 #6
0
def test_query_bbox_geopackage(config_geopackage):
    """Test query with a specified bounding box"""

    psp = SQLiteGPKGProvider(config_geopackage)
    boxed_feature_collection = psp.query(
        bbox=[-16.3991310876, 33.0063015781, -16.3366454278, 33.0560854323]
    )

    assert len(boxed_feature_collection['features']) == 5
コード例 #7
0
def test_query_hits_sqlite_geopackage(config_sqlite):
    """Testing hits results type for sqlite/geopackage"""

    p = SQLiteGPKGProvider(config_sqlite)
    results = p.query(resulttype="hits")
    assert results["numberMatched"] == 177
    results = p.query(bbox=[28.3373, -5.4099, 32.3761, -3.3924],
                      properties=[("continent", "Africa")],
                      resulttype="hits")
    assert results["numberMatched"] == 3
コード例 #8
0
def test_query_bbox_sqlite_geopackage(config_sqlite):
    """Test query with a specified bounding box"""

    psp = SQLiteGPKGProvider(config_sqlite)
    boxed_feature_collection = psp.query(
        bbox=[29.3373, -3.4099, 29.3761, -3.3924])

    assert len(boxed_feature_collection['features']) == 1
    assert 'Burundi' in \
        boxed_feature_collection['features'][0]['properties']['name']
コード例 #9
0
def test_query_with_property_filter_bbox_geopackage(config_geopackage):
    """Test query  valid features when filtering by property"""
    p = SQLiteGPKGProvider(config_geopackage)
    feature_collection = p.query(properties=[("fclass", "cafe")],
                                 bbox=[
                                     -16.3991310876,
                                     33.0063015781,
                                     -16.3366454278,
                                     33.0560854323
                                     ])
    features = feature_collection.get('features', None)
    assert len(features) == 0
コード例 #10
0
def test_query_geopackage(config_geopackage):
    """Testing query for a valid JSON object with geometry for geopackage"""

    p = SQLiteGPKGProvider(config_geopackage)
    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
コード例 #11
0
def test_get_geopackage_not_existing_item_raise_exception(config_geopackage):
    """Testing query for a not existing object"""
    p = SQLiteGPKGProvider(config_geopackage)
    with pytest.raises(ProviderItemNotFoundError):
        p.get(-1)