def test_getegrid_address(): with 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', 'postalcode': '4410', 'localisation': 'test', 'number': '10' }) webservice = PlrWebservice(request) response = webservice.get_egrid_address().json with open(schema_json_extract) as f: schema = json.loads(f.read()) Draft4Validator.check_schema(schema) validator = Draft4Validator(schema) 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_address_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}/{postalcode}/{localisation}/{number} request.matchdict.update({'format': u'json'}) webservice = PlrWebservice(request) response = webservice.get_egrid_address() assert response.code == 400
def test_getegrid_address_missing_parameter(): webservice = PlrWebservice(MockRequest()) with pytest.raises(HTTPBadRequest): webservice.get_egrid_address()