def test_cql_filter_add_no_additional_no_geometrytype_filter(): gs = GeoServer(GS_URL) inputs = ('Point', 'shape', False) cql_filter = gs.construct_cql_for_geometrytype(*inputs) additional_inputs = (cql_filter, None) print 'Test geometrytype cql filter supression with no additional filter' tools.assert_is_none(gs.add_additional_filter(*additional_inputs))
def test_wfs_get_feature_preflight_no_wfs(): gs = GeoServer(GS_URL) inputs = (GS_WORKSPACE_NO_WFS, GS_LYRNAME_NO_WFS) print 'Test preflight wfs with no wfs enabled' data = gs.do_preflight_wfs(*inputs) tools.assert_in('wfs_available', data) tools.assert_false(data['wfs_available'])
def test_wfs_get_feature_preflight(): gs = GeoServer(GS_URL) inputs = (GS_WORKSPACE, GS_LYRNAME) print 'Test preflight wfs' data = gs.do_preflight_wfs(*inputs) tools.assert_in('wfs_available', data) tools.assert_in('features_present', data) tools.assert_in('geometry_name', data)
def test_cql_filter_add_additional_no_geometrytype_filter(): gs = GeoServer(GS_URL) inputs = ('Point', 'shape', False) cql_filter = gs.construct_cql_for_geometrytype(*inputs) additional_inputs = (cql_filter, 'the_meaning=42') print 'Test geometrytype cql filter supression with additional filter' expect = "(the_meaning=42)" tools.assert_equals(gs.add_additional_filter(*additional_inputs), expect)
def test_cql_filter_add_additional(): gs = GeoServer(GS_URL) inputs = ('Point', 'shape') cql_filter = gs.construct_cql_for_geometrytype(*inputs) additional_inputs = (cql_filter, 'the_meaning=42') expect = "(((geometryType(shape)='Point')OR(geometryType(shape)='MultiPoint')))AND(the_meaning=42)" print 'Test CQL geometrytype filter construct and add additional' tools.assert_equals(gs.add_additional_filter(*additional_inputs), expect)
def test_get_map_gs_linestring(): out_filename = 'test_img/get_map_gs_linestring.png' gs = GeoServer(GS_URL) inputs = (GS_LYRNAME, 'LineString', GS_LYRGEOMNAME, GS_LYRBBOX_POLYGON, GS_LYRSRS) img = gs.get_map(*inputs) print 'Test GetMap with previously checked location (linestring feature)' tools.assert_is_instance(img, PngImageFile) img.save(out_filename, 'PNG')
def test_get_map_gs_point(): out_filename = 'test_img/get_map_gs_point.png' gs = GeoServer(GS_URL) inputs = (GS_LYRNAME, 'Point', GS_LYRGEOMNAME, GS_LYRBBOX_POINT, GS_LYRSRS) img = gs.get_map(*inputs) print 'Test GetMap with previously checked location (point feature)' tools.assert_is_instance(img, PngImageFile) tools.assert_is_not_none(img.getbbox()) img.save(out_filename, 'PNG')
def test_get_feature_point(): gs = GeoServer(GS_URL) inputs = (GS_LYRNAME, 'Point') print 'Test GetFeature on %s for sample Point/MultiPoint' % GS_LYRNAME feature = gs.get_feature(*inputs) if feature != None: tools.assert_is_instance(feature, dict) tools.assert_in('id', feature) tools.assert_in('geometry', feature) tools.assert_in(feature['geometry']['type'], ['Point', 'MultiPoint'])
def test_get_feature_linestring(): gs = GeoServer(GS_URL) inputs = (GS_LYRNAME, 'LineString') print 'Test GetFeature on %s for sample LineString/MultiLineString' % GS_LYRNAME feature = gs.get_feature(*inputs) if feature != None: tools.assert_is_instance(feature, dict) tools.assert_in('id', feature) tools.assert_in('geometry', feature) tools.assert_in(feature['geometry']['type'], ['LineString', 'MultiLineString'])
def test_wfs_get_feature_preflight_no_layer(): gs = GeoServer(GS_URL) inputs = ('black', 'black:magic') print 'Test preflight wfs with false layername' data = gs.do_preflight_wfs(*inputs)
def test_service_url_no_workspace(): gs = GeoServer(GS_URL) inputs = None expect = '%s/ows' % GS_URL print 'Test service url with NO workspace' tools.assert_equals(gs.service_url(inputs), expect)
def test_service_url(): gs = GeoServer(GS_URL) inputs = 'rumpelstiltskin' expect = '%s/rumpelstiltskin/ows' % GS_URL print 'Test service url with workspace' tools.assert_equals(gs.service_url(inputs), expect)
def test_split_layername_no_workspace(): gs = GeoServer(GS_URL) inputs = 'abracadabra' expect = (None, 'abracadabra') print 'Test split layername with no workspace' tools.assert_equals(gs.split_layername(inputs), expect)
def test_cql_filter_construct_geometrytype_polygon_wrong_spelling(): gs = GeoServer(GS_URL) inputs = ('polygon', 'shape') print 'Test CQL geometrytype filter construct for "polygon" not "Polygon"' gs.construct_cql_for_geometrytype(*inputs)
def test_cql_filter_construct_geometrytype_unknown_type(): gs = GeoServer(GS_URL) inputs = ('LinearRing', 'shape') print 'Test CQL geometrytype filter construct for unknown type ("LinearRing")' gs.construct_cql_for_geometrytype(*inputs)
def test_split_layername(): gs = GeoServer(GS_URL) inputs = 'black:magic' expect = ('black', 'magic') print 'Test split layername' tools.assert_equals(gs.split_layername(inputs), expect)
def test_cql_filter_construct_geometrytype_point(): gs = GeoServer(GS_URL) inputs = ('Point', 'shape') expect = "((geometryType(shape)='Point')OR(geometryType(shape)='MultiPoint'))" print 'Test CQL geometrytype filter construct for point (check spelling!)' tools.assert_equals(gs.construct_cql_for_geometrytype(*inputs), expect)
def test_geometrytype_cql_filter_construct_supression(): gs = GeoServer(GS_URL) inputs = ('MultiPolygon', 'shape', False) print 'Test CQL geometrytype filter construct supression' tools.assert_is_none(gs.construct_cql_for_geometrytype(*inputs))