Ejemplo n.º 1
0
 def clean(self, value, row=None, *args, **kwargs):
     project_name = row["project_name"]
     gps_code = row["gps_code"]
     cleaned_coordinates = InfrastructureProjectPart.clean_coordinates(
         gps_code)
     provinces = InfrastructureProjectPart.get_provinces(
         cleaned_coordinates=cleaned_coordinates, project_name=project_name)
     value = "".join([province for province in provinces])
     return value
 def test_success_simple_format(self):
     raw_coord_string = "-26.378582,27.654933"
     cleaned_coord_object = InfrastructureProjectPart._parse_coordinate(
         raw_coord_string)
     self.assertEqual(cleaned_coord_object, {
         "latitude": -26.378582,
         "longitude": 27.654933
     })
 def test_success_build_expenditure_item(self):
     expenditure_item = InfrastructureProjectPart._build_expenditure_item(
         self.project)
     self.assertEqual(
         expenditure_item,
         {
             "year": self.project.financial_year,
             "amount": self.project.amount,
             "budget_phase": self.project.budget_phase,
         },
     )
 def test_empty_response_for_invalid_value(self):
     raw_coordinate_string = "test string with, no coords and"
     coords = InfrastructureProjectPart.clean_coordinates(
         raw_coordinate_string)
     self.assertEqual(coords, [])
 def test_success_multiple_coordinates(self):
     raw_coordinate_string = "-26.378582,27.654933 and -22.111222,23.333444"
     coords = InfrastructureProjectPart.clean_coordinates(
         raw_coordinate_string)
     self.assertIn({"latitude": -26.378582, "longitude": 27.654933}, coords)
     self.assertIn({"latitude": -22.111222, "longitude": 23.333444}, coords)
 def test_success_province_from_name(self):
     province = InfrastructureProjectPart._get_province_from_project_name(
         "Eastern Cape: A New Test")
     self.assertEqual(province, "Eastern Cape")
 def test_success_no_results(self, mock_get):
     province = InfrastructureProjectPart._get_province_from_coord(
         self.test_coordinates_two)
     self.assertEqual(province, None)
 def test_success_one_result(self, mock_get):
     province = InfrastructureProjectPart._get_province_from_coord(
         self.test_coordinates_one)
     self.assertEqual(province, "Fake Province 1")