Пример #1
0
def test_query_with_property_filter(config):
    """Test query  valid features when filtering by property"""
    p = PostgreSQLProvider(config)
    feature_collection = p.query(properties=[("waterway", "stream")])
    features = feature_collection.get('features', None)
    stream_features = list(
        filter(lambda feature: feature['properties']['waterway'] == 'stream',
               features))
    assert (len(features) == len(stream_features))

    feature_collection = p.query()
    features = feature_collection.get('features', None)
    stream_features = list(
        filter(lambda feature: feature['properties']['waterway'] == 'stream',
               features))
    other_features = list(
        filter(lambda feature: feature['properties']['waterway'] != 'stream',
               features))
    assert (len(features) != len(stream_features))
    assert (len(other_features) != 0)
Пример #2
0
def test_query(config):
    """Testing query for a valid JSON object with geometry"""
    p = PostgreSQLProvider(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
Пример #3
0
def test_query_with_config_properties(config_with_properties):
    """
    Test that query is restricted by properties in the config.
    No properties should be returned that are not requested.
    Note that not all requested properties have to exist in the query result.
    """
    p = PostgreSQLProvider(config_with_properties)
    feature_collection = p.query()
    feature = feature_collection.get('features', None)[0]
    properties = feature.get('properties', None)
    for property_name in properties.keys():
        assert property_name in config_with_properties["properties"]
Пример #4
0
def test_query_bbox(config):
    """Test query with a specified bounding box"""
    psp = PostgreSQLProvider(config)
    boxed_feature_collection = psp.query(
        bbox=[29.3373, -3.4099, 29.3761, -3.3924])
    assert len(boxed_feature_collection['features']) == 5
Пример #5
0
def test_query_select_properties(config):
    """Test query with selected properties"""
    psp = PostgreSQLProvider(config)
    props = psp.query(select_properties=['name'])
    assert len(props['features'][0]['properties']) == 1
Пример #6
0
def test_query_skip_geometry(config):
    """Test query without geometry"""
    psp = PostgreSQLProvider(config)
    skipped = psp.query(skip_geometry=True)
    assert skipped['features'][0]['geometry'] is None