コード例 #1
0
    def test_fetch_production(self, el_hierro, gran_canaria, gomera,
                              lanza_fuerte, palma, tene):
        self.empty_production = get(1514673600).datetime
        el_hierro.return_value = []
        gran_canaria.return_value = []
        gomera.return_value = []
        lanza_fuerte.return_value = [
            Response(self.morning, 25.0, 1.5, 2.0, 0.5, 2.5, 2.5, 0.4, 5.0),
            Response(self.afternoon, 200.1, 182.0, 12.2, 3.1, 0.0, 0.0, 5.3,
                     0.0),
            Response(self.evening, 28.0, 1.5, 2.0, 0.5, 2.5, 2.5, 0.4, 5.0),
            Response(self.empty_production, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                     0.0)
        ]
        palma.return_value = []
        tene.return_value = []

        data = ES_CN.fetch_production('ES-CN-FVLZ', self.session)
        self.assertIsNotNone(data)
        self.assertIs(len(data), 3)
        for production in data:
            self.assertEqual(production['countryCode'], 'ES-CN-FVLZ')
            self.assertEqual(production['source'], 'demanda.ree.es')
            self.assertIsNotNone(production['datetime'])
            self.assertIsNotNone(production['production'])
            self.assertIsNotNone(production['storage'])
            self.assertTrue(production['datetime'] == self.morning
                            or production['datetime'] == self.afternoon
                            or production['datetime'] == self.evening)
            if self.morning == production['datetime']:
                self.assertEqual(production['production']['gas'], 4.5)
                self.assertEqual(production['production']['oil'], 4.0)
                self.assertEqual(production['production']['hydro'], 5.0)
                self.assertEqual(production['production']['solar'], 0.4)
                self.assertEqual(production['production']['wind'], 0.5)
                self.assertEqual(production['storage']['hydro'], 0.0)
            elif self.afternoon == production['datetime']:
                self.assertEqual(production['production']['gas'], 12.2)
                self.assertEqual(production['production']['oil'], 182.0)
                self.assertEqual(production['production']['hydro'], 0.0)
                self.assertEqual(production['production']['solar'], 5.3)
                self.assertEqual(production['production']['wind'], 3.1)
                self.assertEqual(production['storage']['hydro'], 0.0)
            elif self.evening == production['datetime']:
                self.assertEqual(production['production']['gas'], 4.5)
                self.assertEqual(production['production']['oil'], 4.0)
                self.assertEqual(production['production']['hydro'], 5.0)
                self.assertEqual(production['production']['solar'], 0.4)
                self.assertEqual(production['production']['wind'], 0.5)
                self.assertEqual(production['storage']['hydro'], 0.0)
コード例 #2
0
    def test_fetch_production(self, el_hierro, gran_canaria, gomera,
                              lanza_fuerte, palma, tene):
        self.empty_production = get(1514673600).datetime
        el_hierro.return_value = []
        gran_canaria.return_value = []
        gomera.return_value = []
        lanza_fuerte.return_value = [
            Response(self.morning, 64.4, 1.5, 52.0, 0.5, 2.5, 2.5, 0.4, 5.0),
            Response(self.afternoon, 200.1, 182.0, 12.2, 3.1, 0.0, 0.0, 5.3,
                     0.0),
            Response(self.evening, 54.4, 1.5, 42.0, 0.5, 2.5, 2.5, 0.4, 5.0),
            Response(self.empty_production, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                     0.0),
        ]
        palma.return_value = []
        tene.return_value = []

        data = ES_CN.fetch_production("ES-CN-FVLZ", self.session)
        self.assertIsNotNone(data)
        self.assertIs(len(data), 3)
        for production in data:
            self.assertEqual(production["zoneKey"], "ES-CN-FVLZ")
            self.assertEqual(production["source"], "demanda.ree.es")
            self.assertIsNotNone(production["datetime"])
            self.assertIsNotNone(production["production"])
            self.assertIsNotNone(production["storage"])
            self.assertTrue(production["datetime"] == self.morning
                            or production["datetime"] == self.afternoon
                            or production["datetime"] == self.evening)
            if self.morning == production["datetime"]:
                self.assertEqual(production["production"]["gas"], 0.0)
                self.assertEqual(production["production"]["oil"], 58.5)
                self.assertEqual(production["production"]["hydro"], 5.0)
                self.assertEqual(production["production"]["solar"], 0.4)
                self.assertEqual(production["production"]["wind"], 0.5)
                self.assertEqual(production["storage"]["hydro"], 0.0)
            elif self.afternoon == production["datetime"]:
                self.assertEqual(production["production"]["gas"], 0.0)
                self.assertEqual(production["production"]["oil"], 194.2)
                self.assertEqual(production["production"]["hydro"], 0.0)
                self.assertEqual(production["production"]["solar"], 5.3)
                self.assertEqual(production["production"]["wind"], 3.1)
                self.assertEqual(production["storage"]["hydro"], 0.0)
            elif self.evening == production["datetime"]:
                self.assertEqual(production["production"]["gas"], 0.0)
                self.assertEqual(production["production"]["oil"], 48.5)
                self.assertEqual(production["production"]["hydro"], 5.0)
                self.assertEqual(production["production"]["solar"], 0.4)
                self.assertEqual(production["production"]["wind"], 0.5)
                self.assertEqual(production["storage"]["hydro"], 0.0)
コード例 #3
0
    def test_fetch_production_el_hierro(self, el_hierro, gran_canaria, gomera,
                                        lanza_fuerte, palma, tene):
        self.empty_production = get(1514673600).datetime
        el_hierro.return_value = [
            Response(self.morning, 10.0, 1.5, 2.0, 0.5, 2.5, 2.5, 0.4, 5.0),
            Response(self.afternoon, 5.6, 1.7, 0.0, 1.6, 0.0, 0.0, 0.0, 2.4),
            Response(self.evening, 12.0, 0.0, 2.0, 0.5, 2.5, 0.0, 0.0, 3.0),
            Response(self.empty_production, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                     0.0),
        ]
        gran_canaria.return_value = []
        gomera.return_value = []
        lanza_fuerte.return_value = []
        palma.return_value = []
        tene.return_value = []

        data = ES_CN.fetch_production("ES-CN-HI", self.session)
        self.assertIsNotNone(data)
        self.assertIs(len(data), 3)
        for production in data:
            self.assertEqual(production["zoneKey"], "ES-CN-HI")
            self.assertEqual(production["source"], "demanda.ree.es")
            self.assertIsNotNone(production["datetime"])
            self.assertIsNotNone(production["production"])
            self.assertIsNotNone(production["storage"])
            self.assertTrue(production["datetime"] == self.morning
                            or production["datetime"] == self.afternoon
                            or production["datetime"] == self.evening)
            if self.morning == production["datetime"]:
                self.assertEqual(production["production"]["gas"], 0.0)
                self.assertEqual(production["production"]["oil"], 8.5)
                self.assertEqual(production["production"]["hydro"], 0.0)
                self.assertEqual(production["production"]["solar"], 0.4)
                self.assertEqual(production["production"]["wind"], 0.5)
                self.assertEqual(production["storage"]["hydro"], -5.0)
            elif self.afternoon == production["datetime"]:
                self.assertEqual(production["production"]["gas"], 0.0)
                self.assertEqual(production["production"]["oil"], 1.7)
                self.assertEqual(production["production"]["hydro"], 0.0)
                self.assertEqual(production["production"]["solar"], 0.0)
                self.assertEqual(production["production"]["wind"], 1.6)
                self.assertEqual(production["storage"]["hydro"], -2.4)
            elif self.evening == production["datetime"]:
                self.assertEqual(production["production"]["gas"], 0.0)
                self.assertEqual(production["production"]["oil"], 4.5)
                self.assertEqual(production["production"]["hydro"], 0.0)
                self.assertEqual(production["production"]["solar"], 0.0)
                self.assertEqual(production["production"]["wind"], 0.5)
                self.assertEqual(production["storage"]["hydro"], -3.0)
コード例 #4
0
ファイル: test_ES_CN.py プロジェクト: tillz/electricitymap
    def test_fetch_production_el_hierro(self, el_hierro, gran_canaria, gomera,
                                        lanza_fuerte, palma, tene):
        self.empty_production = get(1514673600).datetime
        el_hierro.return_value = [
            Response(self.morning, 10.0, 1.5, 2.0, 0.5, 2.5, 2.5, 0.4, 5.0),
            Response(self.afternoon, 5.6, 1.7, 0.0, 1.6, 0.0, 0.0, 0.0, 2.4),
            Response(self.evening, 12.0, 2.0, 2.0, 0.5, 2.5, 2.5, 0.0, 3.0),
            Response(self.empty_production, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                     0.0)
        ]
        gran_canaria.return_value = []
        gomera.return_value = []
        lanza_fuerte.return_value = []
        palma.return_value = []
        tene.return_value = []

        data = ES_CN.fetch_production('ES-CN-HI', self.session)
        self.assertIsNotNone(data)
        self.assertIs(len(data), 3)
        for production in data:
            self.assertEqual(production['zoneKey'], 'ES-CN-HI')
            self.assertEqual(production['source'], 'demanda.ree.es')
            self.assertIsNotNone(production['datetime'])
            self.assertIsNotNone(production['production'])
            self.assertIsNotNone(production['storage'])
            self.assertTrue(production['datetime'] == self.morning
                            or production['datetime'] == self.afternoon
                            or production['datetime'] == self.evening)
            if self.morning == production['datetime']:
                self.assertEqual(production['production']['gas'], 4.5)
                self.assertEqual(production['production']['oil'], 4.0)
                self.assertEqual(production['production']['hydro'], 0.0)
                self.assertEqual(production['production']['solar'], 0.4)
                self.assertEqual(production['production']['wind'], 0.5)
                self.assertEqual(production['storage']['hydro'], -5.0)
            elif self.afternoon == production['datetime']:
                self.assertEqual(production['production']['gas'], 0.0)
                self.assertEqual(production['production']['oil'], 1.7)
                self.assertEqual(production['production']['hydro'], 0.0)
                self.assertEqual(production['production']['solar'], 0.0)
                self.assertEqual(production['production']['wind'], 1.6)
                self.assertEqual(production['storage']['hydro'], -2.4)
            elif self.evening == production['datetime']:
                self.assertEqual(production['production']['gas'], 4.5)
                self.assertEqual(production['production']['oil'], 4.5)
                self.assertEqual(production['production']['hydro'], 0.0)
                self.assertEqual(production['production']['solar'], 0.0)
                self.assertEqual(production['production']['wind'], 0.5)
                self.assertEqual(production['storage']['hydro'], -3.0)
コード例 #5
0
ファイル: test_ES_CN.py プロジェクト: alfurey/electricitymap
    def test_fetch_production(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_production('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.assertIsNotNone(data['production'])
            self.assertEqual(data['production']['hydro'], 250.0)
            self.assertIsNotNone(data['storage'])
            self.assertEqual(data['storage']['hydro'], -50.0)
        except Exception as ex:
            self.fail(ex.message)
コード例 #6
0
    def test_fetch_production(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_production('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.assertIsNotNone(data['production'])
            self.assertEqual(data['production']['hydro'], 250.0)
            self.assertIsNotNone(data['storage'])
            self.assertEqual(data['storage']['hydro'], -50.0)
        except Exception as ex:
            self.fail(ex.message)
コード例 #7
0
    def test_fetch_production(self, el_hierro, gran_canaria, gomera,
                              lanza_fuerte, palma, tene):
        self.empty_production = get(1514673600).datetime
        el_hierro.return_value = [
            Response(self.morning, 10.0, 1.5, 2.0, 0.5, 2.5, 2.5, 0.4, 5.0),
            Response(self.afternoon, 5.6, 1.7, 0.0, 1.6, 0.0, 0.0, 0.0, 2.4),
            Response(self.evening, 12.0, 2.0, 2.0, 0.5, 2.5, 2.5, 0.0, 3.0),
            Response(self.empty_production, 12.0, 2.0, 2.0, 0.5, 2.5, 2.5, 0.0,
                     3.0)
        ]

        gran_canaria.return_value = [
            Response(self.morning, 15.0, 1.5, 2.0, 0.5, 2.5, 2.5, 0.4, 5.0),
            Response(self.afternoon, 443.6, 34.7, 0.0, 33.3, 172.4, 184.5,
                     17.5, 0.0),
            Response(self.evening, 18.0, 1.5, 2.0, 0.5, 2.5, 2.5, 0.4, 5.0),
            Response(self.empty_production, 12.0, 2.0, 2.0, 0.5, 2.5, 2.5, 0.0,
                     3.0)
        ]
        gomera.return_value = [
            Response(self.morning, 5.0, 1.5, 2.0, 0.5, 2.5, 2.5, 0.4, 5.0),
            Response(self.afternoon, 9.3, 9.3, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
            Response(self.evening, 8.0, 1.5, 2.0, 0.5, 2.5, 2.5, 0.4, 5.0),
            Response(self.empty_production, 12.0, 2.0, 2.0, 0.5, 2.5, 2.5, 0.0,
                     3.0)
        ]
        lanza_fuerte.return_value = [
            Response(self.morning, 25.0, 1.5, 2.0, 0.5, 2.5, 2.5, 0.4, 5.0),
            Response(self.afternoon, 200.1, 182.0, 12.2, 3.1, 0.0, 0.0, 5.3,
                     0.0),
            Response(self.evening, 28.0, 1.5, 2.0, 0.5, 2.5, 2.5, 0.4, 5.0),
            Response(self.empty_production, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                     0.0)
        ]
        palma.return_value = [
            Response(self.morning, 30.0, 1.5, 2.0, 0.5, 2.5, 2.5, 0.4, 5.0),
            Response(self.afternoon, 34.7, 30.2, 0.0, 3.3, 0.0, 0.0, 2.1, 0.0),
            Response(self.evening, 32.0, 1.5, 2.0, 0.5, 2.5, 2.5, 0.4, 5.0),
            Response(self.empty_production, 12.0, 2.0, 2.0, 0.5, 2.5, 2.5, 0.0,
                     3.0)
        ]
        tene.return_value = [
            Response(self.morning, 20.0, 1.5, 2.0, 0.5, 2.5, 2.5, 0.4, 5.0),
            Response(self.afternoon, 452.6, 34.9, 0.0, 28.2, 143.8, 179.2,
                     66.3, 0.0),
            Response(self.evening, 22.0, 1.5, 2.0, 0.5, 2.5, 2.5, 0.4, 5.0),
            Response(self.empty_production, 12.0, 2.0, 2.0, 0.5, 2.5, 2.5, 0.0,
                     3.0)
        ]

        data = ES_CN.fetch_production('ES-CN', self.session)
        self.assertIsNotNone(data)
        self.assertIs(len(data), 3)
        for production in data:
            self.assertEqual(production['countryCode'], 'ES-CN')
            self.assertEqual(production['source'], 'demanda.ree.es')
            self.assertIsNotNone(production['datetime'])
            self.assertIsNotNone(production['production'])
            self.assertIsNotNone(production['storage'])
            self.assertTrue(production['datetime'] == self.morning
                            or production['datetime'] == self.afternoon
                            or production['datetime'] == self.evening)
            if self.morning == production['datetime']:
                self.assertEqual(production['production']['gas'], 27.0)
                self.assertEqual(production['production']['oil'], 24.0)
                self.assertEqual(production['production']['hydro'], 25.0)
                self.assertEqual(production['production']['solar'], 2.4)
                self.assertEqual(production['production']['wind'], 3.0)
                self.assertEqual(production['storage']['hydro'], -5.0)
            elif self.afternoon == production['datetime']:
                self.assertEqual(production['production']['gas'], 328.4)
                self.assertEqual(production['production']['oil'], 656.5)
                self.assertEqual(production['production']['hydro'], 0.0)
                self.assertEqual(production['production']['solar'], 91.2)
                self.assertEqual(production['production']['wind'], 69.5)
                self.assertEqual(production['storage']['hydro'], -2.4)
            elif self.evening == production['datetime']:
                self.assertEqual(production['production']['gas'], 27.0)
                self.assertEqual(production['production']['oil'], 24.5)
                self.assertEqual(production['production']['hydro'], 25.0)
                self.assertEqual(production['production']['solar'], 2.0)
                self.assertEqual(production['production']['wind'], 3.0)
                self.assertEqual(production['storage']['hydro'], -3.0)