def test_rounding(self): """Should round volcano locations to 6 DP""" expected_args = [ call(sentinel.longitude, 6), call(sentinel.latitude, 6) ] format_volcano_data(self.StubVolcano()) self.assertEqual(expected_args, self._patched_round.call_args_list)
def get_country_volcanoes(country_id): country = session.query(Country).get(country_id) volcanoes_queryset = session.query(Volcano).filter(Volcano.geom.ST_Within(country.geom)) data = [format_volcano_data(volcano) for volcano in volcanoes_queryset] return data
def volcano_intersect(volcano_id): volcano = session.query(Volcano).get(volcano_id) country = session.query(Country).filter(Country.geom.ST_Intersects(volcano.geom)).first() if country is None: return redirect('/volcano/api/v0.1/volcano/' + str(volcano_id)) continent = session.query(Continent).filter(Continent.geom.ST_Intersects(volcano.geom)).first() data = [ format_volcano_data(volcano), format_area_data(country), format_area_data(country, continent=continent), ] return as_json(data)
def test_result(self): """Should return expected results""" self._patched_round.side_effect = [ sentinel.longitude_rounded, sentinel.latitude_rounded ] expected_result = { 'type': 'Feature', 'properties': { 'name': sentinel.name, 'id': sentinel.id }, 'geometry': { 'type': 'Point', 'coordinates': [sentinel.longitude_rounded, sentinel.latitude_rounded], }, } result = format_volcano_data(self.StubVolcano()) self.assertEqual(expected_result, result)
def get_volcano_name(volcano_name): volcanoes_queryset = session.query(Volcano).filter(Volcano.name.like(volcano_name + "%")).all() data = [format_volcano_data(volcano) for volcano in volcanoes_queryset] return data
def get_volcano(volcano_id): volcano = session.query(Volcano).get(volcano_id) data = [format_volcano_data(volcano)] return data
def get_volcanoes(): volcanoes_queryset = session.query(Volcano).all() data = [format_volcano_data(volcano) for volcano in volcanoes_queryset] return data