def test_fetch_consumption_el_hierro(self, el_hierro, gran_canaria, gomera, lanza_fuerte, palma, tene): el_hierro.return_value = [ Response(self.morning, 10.0), Response(self.afternoon, 5.6), Response(self.evening, 12.0) ] gran_canaria.return_value = [] gomera.return_value = [] lanza_fuerte.return_value = [] palma.return_value = [] tene.return_value = [] data = ES_CN.fetch_consumption('ES-CN-HI', self.session) self.assertIsNotNone(data) self.assertIs(len(data), 3) for consumption in data: self.assertEqual(consumption['countryCode'], 'ES-CN-HI') self.assertEqual(consumption['source'], 'demanda.ree.es') self.assertIsNotNone(consumption['datetime']) self.assertTrue(consumption['datetime'] == self.morning or consumption['datetime'] == self.afternoon or consumption['datetime'] == self.evening) if self.morning == consumption['datetime']: self.assertEqual(consumption['consumption'], 10.0) elif self.afternoon == consumption['datetime']: self.assertEqual(consumption['consumption'], 5.6) elif self.evening == consumption['datetime']: self.assertEqual(consumption['consumption'], 12.0)
def test_fetch_consumption_el_hierro(self, el_hierro, gran_canaria, gomera, lanza_fuerte, palma, tene): el_hierro.return_value = [ Response(self.morning, 10.0), Response(self.afternoon, 5.6), Response(self.evening, 12.0), ] gran_canaria.return_value = [] gomera.return_value = [] lanza_fuerte.return_value = [] palma.return_value = [] tene.return_value = [] data = ES_CN.fetch_consumption("ES-CN-HI", self.session) self.assertIsNotNone(data) self.assertIs(len(data), 3) for consumption in data: self.assertEqual(consumption["zoneKey"], "ES-CN-HI") self.assertEqual(consumption["source"], "demanda.ree.es") self.assertIsNotNone(consumption["datetime"]) self.assertTrue(consumption["datetime"] == self.morning or consumption["datetime"] == self.afternoon or consumption["datetime"] == self.evening) if self.morning == consumption["datetime"]: self.assertEqual(consumption["consumption"], 10.0) elif self.afternoon == consumption["datetime"]: self.assertEqual(consumption["consumption"], 5.6) elif self.evening == consumption["datetime"]: self.assertEqual(consumption["consumption"], 12.0)
def test_fetch_consumption(self, el_hierro, gran_canaria, gomera, lanza_fuerte, palma, tene): el_hierro.return_value = [] gran_canaria.return_value = [] gomera.return_value = [] lanza_fuerte.return_value = [ Response(self.morning, 64.4), Response(self.afternoon, 200.1), Response(self.evening, 54.4) ] palma.return_value = [] tene.return_value = [] data = ES_CN.fetch_consumption('ES-CN-FVLZ', self.session) self.assertIsNotNone(data) self.assertIs(len(data), 3) for consumption in data: self.assertEqual(consumption['zoneKey'], 'ES-CN-FVLZ') self.assertEqual(consumption['source'], 'demanda.ree.es') self.assertIsNotNone(consumption['datetime']) self.assertTrue(consumption['datetime'] == self.morning or consumption['datetime'] == self.afternoon or consumption['datetime'] == self.evening) if self.morning == consumption['datetime']: self.assertEqual(consumption['consumption'], 64.4) elif self.afternoon == consumption['datetime']: self.assertEqual(consumption['consumption'], 200.1) elif self.evening == consumption['datetime']: self.assertEqual(consumption['consumption'], 54.4)
def test_fetch_consumption(self, el_hierro, gran_canaria, gomera, lanza_fuerte, palma, tene): el_hierro.return_value = [ Response(self.morning, 10.0), Response(self.afternoon, 5.6), Response(self.evening, 12.0) ] gran_canaria.return_value = [ Response(self.morning, 15.0), Response(self.afternoon, 443.6), Response(self.evening, 18.0) ] gomera.return_value = [ Response(self.morning, 5.0), Response(self.afternoon, 9.3), Response(self.evening, 8.0) ] lanza_fuerte.return_value = [ Response(self.morning, 25.0), Response(self.afternoon, 200.1), Response(self.evening, 28.0) ] palma.return_value = [ Response(self.morning, 30.0), Response(self.afternoon, 34.7), Response(self.evening, 32.0) ] tene.return_value = [ Response(self.morning, 20.0), Response(self.afternoon, 452.6), Response(self.evening, 22.0) ] data = ES_CN.fetch_consumption('ES-CN', self.session) self.assertIsNotNone(data) self.assertIs(len(data), 3) for consumption in data: self.assertEqual(consumption['countryCode'], 'ES-CN') self.assertEqual(consumption['source'], 'demanda.ree.es') self.assertIsNotNone(consumption['datetime']) self.assertTrue(consumption['datetime'] == self.morning or consumption['datetime'] == self.afternoon or consumption['datetime'] == self.evening) if self.morning == consumption['datetime']: self.assertEqual(consumption['consumption'], 105.0) elif self.afternoon == consumption['datetime']: self.assertEqual(consumption['consumption'], 1145.9) elif self.evening == consumption['datetime']: self.assertEqual(consumption['consumption'], 120.0)
def test_fetch_consumption(self, el_hierro_get, canaria_get, gomera_get, lanza_get, palma_get, tene_get): el_hierro_get.return_value = self.mocked_response canaria_get.return_value = self.mocked_response gomera_get.return_value = self.mocked_response lanza_get.return_value = self.mocked_response palma_get.return_value = self.mocked_response tene_get.return_value = self.mocked_response try: data = ES_CN.fetch_consumption('ES-CN', self.session) self.assertIsNotNone(data) self.assertEqual(data['countryCode'], 'ES-CN') self.assertEqual(data['source'], 'demanda.ree.es') self.assertIsNotNone(data['datetime']) self.assertEqual(data['consumption'], 6000.0) except Exception as ex: self.fail(ex.message)