def test_get_egrid_coord(pyramid_oereb_test_config, params): request = MockRequest( current_route_url='http://example.com/oereb/getegrid/json') # Add params to matchdict as the view will do it for /getegrid/{format}/ request.matchdict.update({'format': u'json'}) request.params.update(params) webservice = PlrWebservice(request) webservice.get_egrid()
def test_getegrid_ident(pyramid_oereb_test_config, schema_json_extract, geometry, real_estate_data): request = MockRequest( current_route_url='http://example.com/oereb/getegrid/json/BLTEST/1000') # Add params to matchdict as the view will do it for /getegrid/{format}/{identdn}/{number} request.matchdict.update({'format': u'json'}) request.params.update({'IDENTDN': u'BLTEST', 'NUMBER': u'1000'}) if geometry: request.params.update({'GEOMETRY': u'true'}) webservice = PlrWebservice(request) response = webservice.get_egrid().json Draft4Validator.check_schema(schema_json_extract) validator = Draft4Validator(schema_json_extract) validator.validate(response) assert isinstance(response, dict) real_estates = response.get('GetEGRIDResponse') assert isinstance(real_estates, list) assert len(real_estates) == 1 assert real_estates[0]['egrid'] == u'TEST' assert real_estates[0]['number'] == u'1000' assert real_estates[0]['identDN'] == u'BLTEST' assert real_estates[0]['type'] == u'Liegenschaft' if geometry: assert 'limit' in real_estates[0] assert 'crs' in real_estates[0]['limit'] assert 'coordinates' in real_estates[0]['limit']
def test_getegrid_address(pyramid_oereb_test_config, schema_json_extract, real_estate_data, address): del pyramid_oereb_test_config request = MockRequest( current_route_url='http://example.com/oereb/getegrid/json/4410/test/10' ) # Add params to matchdict as the view will do it for # /getegrid/{format}/{postalcode}/{localisation}/{number} request.matchdict.update({'format': u'json'}) request.params.update({ 'POSTALCODE': u'4410', 'LOCALISATION': u'test', 'NUMBER': u'10' }) webservice = PlrWebservice(request) response = webservice.get_egrid().json Draft4Validator.check_schema(schema_json_extract) validator = Draft4Validator(schema_json_extract) validator.validate(response) assert isinstance(response, dict) assert response.get('GetEGRIDResponse') is not None assert response.get('GetEGRIDResponse')[0].get('egrid') == u'TEST' assert response.get('GetEGRIDResponse')[0].get('number') == u'1000' assert response.get('GetEGRIDResponse')[0].get('identDN') == u'BLTEST'
def test_getegrid_coord_missing_parameter(): request = MockRequest( current_route_url='http://example.com/oereb/getegrid/json/') # Add params to matchdict as the view will do it for /getegrid/{format}/ request.matchdict.update({'format': u'json'}) webservice = PlrWebservice(request) response = webservice.get_egrid() assert response.code == 400
def test_getegrid_en(pyramid_oereb_test_config, schema_json_extract, real_estate_data): del pyramid_oereb_test_config url = 'http://example.com/oereb/getegrid/json/?EN=2,0' request = MockRequest(current_route_url=url) # Add params to matchdict as the view will do it for /getegrid/{format}/ request.matchdict.update({'format': u'json'}) request.params.update({'EN': '2,0'}) webservice = PlrWebservice(request) response = webservice.get_egrid().json Draft4Validator.check_schema(schema_json_extract) validator = Draft4Validator(schema_json_extract) validator.validate(response) assert isinstance(response, dict) real_estates = response.get('GetEGRIDResponse') assert isinstance(real_estates, list) assert len(real_estates) == 2 assert real_estates[0]['egrid'] == u'TEST' assert real_estates[0]['number'] == u'1000' assert real_estates[0]['identDN'] == u'BLTEST'