def test_view_point_api_v1_json(self): res = self.testapp.get('/api/point/1.json', status='*') self.assertEqual(res.status_int, 200) loaded_json = json.loads(res.body) self.assertEqual(loaded_json['version'], PointAPIv1.version()) self.assertEqual(loaded_json['name'], PointAPIv1.identifier())
def test_view_point_api_v1_json(self): res = self.testapp.get("/api/point/1.json", status="*") self.assertEqual(res.status_int, 200) loaded_json = json.loads(res.body) self.assertEqual(loaded_json["version"], PointAPIv1.version()) self.assertEqual(loaded_json["name"], PointAPIv1.identifier())
def test_to_dict(self): name = PointAPIv1.identifier() description = PointAPIv1.description() version = PointAPIv1.version() the_dict = PointAPIv1.to_dict() self.assertEqual(the_dict["name"], name, msg="Name should match") self.assertEqual(the_dict["description"], description, msg="Description should match") self.assertEqual(the_dict["version"], version, msg="Version should match")
def test_to_dict(self): name = PointAPIv1.identifier() description = PointAPIv1.description() version = PointAPIv1.version() the_dict = PointAPIv1.to_dict() self.assertEqual(the_dict['name'], name, msg="Name should match") self.assertEqual(the_dict['description'], description, msg="Description should match") self.assertEqual(the_dict['version'], version, msg="Version should match")
def test_create_and_render_wfs_map_via_point_api_v1(self): data_url = "https://raw.github.com/BCCVL/BCCVL_Visualiser/master/bccvl_visualiser/tests/fixtures/occurrences.csv" query_string = "request=GetFeature&service=WFS&version=1.1.0&typeName=DEFAULT&outputFormat=geojson" my_map = PointAPIv1(data_url=data_url, query_string=query_string) map_content, map_content_type, retval = my_map.render() self.assertEqual(map_content_type, "application/json; subtype=geojson") self.assertEqual( retval, mapscript.MS_SUCCESS, "Should return success code: %s, but didn't" % mapscript.MS_SUCCESS)
def test_create_and_render_wms_map_via_point_api_v1(self): data_url = "https://raw.github.com/BCCVL/BCCVL_Visualiser/master/bccvl_visualiser/tests/fixtures/occurrences.csv" query_string = "TRANSPARENT=true&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A3857&BBOX=-20037508.34,-10018754.17,-15028131.255,-5009377.085&WIDTH=512&HEIGHT=1024&LAYERS=DEFAULT" my_map = PointAPIv1(data_url=data_url, query_string=query_string) map_content, map_content_type, retval = my_map.render() self.assertEqual(map_content_type, "image/png") self.assertEqual( retval, mapscript.MS_SUCCESS, "Should return success code: %s, but didn't" % mapscript.MS_SUCCESS)
def test_create_and_render_wfs_map_via_point_api_v1__check_content(self): data_url = "https://raw.github.com/BCCVL/BCCVL_Visualiser/master/bccvl_visualiser/tests/fixtures/occurrences.csv" query_string = "request=GetFeature&service=WFS&version=1.1.0&typeName=DEFAULT&outputFormat=geojson" my_map = PointAPIv1(data_url=data_url, query_string=query_string) map_content, map_content_type, retval = my_map.render() expected_content = '''features": [\n \n {\n "type": "Feature",\n "geometry": {\n "type": "Point",\n "coordinates": [32.09, 42.12]\n },\n "properties": {\n }\n },\n \n {\n "type": "Feature",\n "geometry": {\n "type": "Point",\n "coordinates": [45, 21]\n },\n "properties": {\n }\n },\n \n {\n "type": "Feature",\n "geometry": {\n "type": "Point",\n "coordinates": [56.43, 43.22]\n },\n "properties": {\n }\n },\n \n {\n "type": "Feature",\n "geometry": {\n "type": "Point",\n "coordinates": [179, -89.01]\n },\n "properties": {\n }\n }\n ]\n}\n\n''' self.assertEqual(map_content, expected_content) self.assertEqual(map_content_type, "application/json; subtype=geojson") self.assertEqual( retval, mapscript.MS_SUCCESS, "Should return success code: %s, but didn't" % mapscript.MS_SUCCESS)
def wms_data_url(self): log = logging.getLogger(__name__) log.debug('Processing ows request') data_url = None try: data_url = self.request.GET.getone('DATA_URL') except: log.warn('No data_url provided') data_url = None my_map = PointAPIv1(data_url=data_url, query_string=self.request.query_string.strip()) map_content, map_content_type, retval = my_map.render() response = Response(map_content, content_type=map_content_type) return response
def test_version(self): self.assertEqual(PointAPIv1.version(), 1, msg="Version should be 1")
def _to_dict(self): return PointAPIv1.to_dict()