Skip to content

Commit cc14ec3

Browse files
committed
added removed test
1 parent a7218fe commit cc14ec3

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

tests/intensity/test_electricitymaps.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,17 @@ def test_carbon_intensity_by_location_bad_json_response(self, mock_get):
5050
with self.assertRaises(exceptions.CarbonIntensityFetcherError):
5151
self.electricity_map._carbon_intensity_by_location(lon=self.g_location.lng, lat=self.g_location.lat)
5252

53+
@patch("requests.get")
54+
def test_carbon_intensity_by_location_json_response_not_ok(self, mock_get):
55+
mock_response = MagicMock()
56+
mock_response.ok = False
57+
mock_response.json.return_value = {"error": "some error"}
58+
mock_get.return_value = mock_response
59+
60+
with self.assertRaises(exceptions.CarbonIntensityFetcherError):
61+
self.electricity_map._carbon_intensity_by_location(lon=self.g_location.lng, lat=self.g_location.lat)
5362

63+
5464
@patch.object(ElectricityMap, "_carbon_intensity_by_location")
5565
def test_carbon_intensity(self, mock_carbon_intensity_by_location):
5666
mock_carbon_intensity_by_location.return_value = 100.0

0 commit comments

Comments
 (0)