示例#1
0
    def test_get_storm_flod_response(self):
        blox_coordinates = address_to_house_data(
            "Bryghusgade, 1473 København")["coordinates"]
        blox_risk = get_storm_flod_response(blox_coordinates)["risk"]
        self.assertEqual(blox_risk, "medium")

        DIKU_coordinates = address_to_house_data(
            "Universitetsparken 1, 2100 København")["coordinates"]
        DIKU_risk = get_storm_flod_response(DIKU_coordinates)["risk"]
        self.assertEqual(DIKU_risk, "low")
 def test_get_satelite_img(self):
     data = address_to_house_data("Jarmers Pl. 2, 1551 København")
     actual_image = get_satelite_img(data["coordinates"])
     expected_image = Image.open(
         path.join("tests", "test_images",
                   "get_img_map.png")).convert("RGB")
     self.assertEqual(actual_image, expected_image)
示例#3
0
    def test_get_fasting_response_medium(self):
        home_coordinates = address_to_house_data(
            "Kjærmarken 103, 6771 gredstedbro")["coordinates"]
        resp = get_fastning_response(home_coordinates)

        self.assertEqual(resp["risk"], "low")
        self.assertEqual(resp["value"], 44.75)
 def test_bounding_box_espg_25832(self):
     data = address_to_house_data("Kjærmarken 103, 6771 Gredstedbro")
     box = bounding_box(data["coordinates"], ESPG="25832")
     self.assertEqual(
         box,
         "483622.52053322777,6139451.855766358,483736.7176466355,6139564.964581124",
     )
 def test_bounding_box_espg_3857(self):
     data = address_to_house_data("Jarmers Pl. 2, 1551 København")
     box = bounding_box(data["coordinates"], boxSize=200, ESPG="3857")
     self.assertEqual(
         box,
         "1398592.0975429227,7494769.030811637,1398792.0975429227,7494969.030811637",
     )
示例#6
0
    def test_fastning_img_to_value(self):
        office_address = address_to_house_data(
            "Kjærmarken 103, 6771 gredstedbro")["coordinates"]
        fastning_image = get_fastning_img(coordinates=office_address)
        fastning_image_to_value(fastning_image)

        self.assertEqual(fastning_image_to_value(fastning_image), 44.75)
示例#7
0
    def test_get_flood_img(self):
        blox_coordinates = address_to_house_data(
            "Bryghusgade, 1473 København")["coordinates"]
        actual_image = get_storm_flood_img(blox_coordinates)
        expected_image = Image.open(
            path.join("tests", "test_images", "blox_storm_flood.png"))

        self.assertEqual(actual_image, expected_image)
示例#8
0
 def test_get_rain_risk_response_1(self):
     data = address_to_house_data("Kjærmarken 103, 6771 gredstedbro")
     resp = get_rain_risk_response(data["id"], data["coordinates"])
     self.assertEqual(resp["factors"]["basement"]["risk"], "low")
     self.assertEqual(resp["factors"]["fastning"]["risk"], "low")
     self.assertEqual(resp["factors"]["hollowing"]["risk"], "low")
     self.assertEqual(resp["factors"]["conductivity"]["risk"], "low")
     self.assertEqual(resp["risk"], "low")
示例#9
0
 def test_get_rain_risk_response_2(self):
     data = address_to_house_data("Dronning Dagmars Vej 13, 6760 Ribe")
     resp = get_rain_risk_response(data["id"], data["coordinates"])
     self.assertEqual(resp["factors"]["basement"]["risk"], "high")
     self.assertEqual(resp["factors"]["fastning"]["risk"], "medium")
     self.assertEqual(resp["factors"]["hollowing"]["risk"], "high")
     self.assertEqual(resp["factors"]["conductivity"]["risk"], "low")
     self.assertEqual(resp["risk"], "high")
示例#10
0
 def test_get_img_hollowings(self):
     office_address = address_to_house_data(
         "Jarmers Pl. 2, 1551 København")["coordinates"]
     actual_image = get_hollowing_img(office_address, "hollowings")
     expected_image = Image.open(
         path.join("tests", "test_images",
                   "get_img_hollowings.png")).convert("L")
     self.assertEqual(actual_image, expected_image)
示例#11
0
    def test_get_conductivity_img(self):
        office_address = address_to_house_data(
            "Jarmers Pl. 2, 1551 København")["coordinates"]
        actual_image = get_conductivity_img(coordinates=office_address)
        expected_image = Image.open(
            path.join("tests", "test_images",
                      "conductivity_img_office.png")).convert("RGB")

        self.assertEqual(actual_image, expected_image)
示例#12
0
 def test_get_hollowing_response(self):
     office_address = address_to_house_data(
         "Jarmers Pl. 2, 1551 København")["coordinates"]
     resp = get_hollowing_response(office_address)
     actual_image = np.asarray(
         Image.open(BytesIO(base64.b64decode(resp["image"]))))
     expected_image = np.asarray(
         Image.open(
             path.join("tests", "test_images",
                       "jarmars_hollwing_response.png")).convert("RGB"))
     self.assertTrue(np.allclose(actual_image, expected_image, atol=1))
     resp.pop("image")
     self.assertAlmostEqual(resp["house_percentage"], 0.19)
     self.assertAlmostEqual(resp["area_percentage"], 6.83)
示例#13
0
    def test_get_fasting_response_high(self):
        office_address = address_to_house_data(
            "Jarmers Pl. 2, 1551 København")["coordinates"]
        resp = get_fastning_response(office_address)

        self.assertEqual(resp["value"], 51.53)
        self.assertEqual(resp["risk"], "medium")

        actual_image = np.asarray(
            Image.open(BytesIO(base64.b64decode(resp["image"]))))
        expected_image = np.asarray(
            Image.open(
                path.join("tests", "test_images",
                          "fastning_map_office.png")).convert("RGB"))
        self.assertTrue(np.allclose(actual_image, expected_image, atol=1))
示例#14
0
 def test_has_basement(self):
     no_basement_id = address_to_house_data(
         "Kjærmarken 103, 6771 gredstedbro")["id"]
     basement_id = address_to_house_data("Kiærsvej 2, 6760 Ribe")["id"]
     self.assertEqual(get_basement_response(no_basement_id)["risk"], "low")
     self.assertEqual(get_basement_response(basement_id)["risk"], "high")
示例#15
0
 def test_address_to_id_and_coordinates(self):
     data = address_to_house_data("Jarmers Pl. 2, 1551 København")
     self.assertEqual(data["coordinates"], (55.67946496, 12.56466489))
     self.assertEqual(data["id"], "0a3f507a-9dcc-32b8-e044-0003ba298018")
     self.assertEqual(data["isAppartment"], False)
     self.assertEqual(data["navn"], "Jarmers Plads 2, 1551 København V")
示例#16
0
 def test_get_conductivity_response(self):
     office_address = address_to_house_data(
         "Jarmers Pl. 2, 1551 København")["coordinates"]
     resp = get_conductivity_response(office_address)
     self.assertEqual(resp["value"], 125)
     self.assertEqual(resp["risk"], "high")