diff --git a/.github/workflows/python2.7-app.yml b/.github/workflows/python2.7-app.yml index 8c3d3f2..c286aa0 100644 --- a/.github/workflows/python2.7-app.yml +++ b/.github/workflows/python2.7-app.yml @@ -12,7 +12,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 diff --git a/esios/indicators.py b/esios/indicators.py index f19892d..8c5d22a 100644 --- a/esios/indicators.py +++ b/esios/indicators.py @@ -6,6 +6,8 @@ class Indicator(base.RESTResource): path = 'indicators' + time_trunc = 'hour' + time_agg = 'sum' @base.apimethod def get(self, start_date, end_date): @@ -15,11 +17,12 @@ def get(self, start_date, end_date): raise Exception('Start date must have time zone') if end_date.tzinfo is None: raise Exception('End date must have time zone') - time_trunc = 'hour' + time_trunc = self.time_trunc + time_agg = self.time_agg start_date = start_date.isoformat() end_date = end_date.isoformat() params = base.get_params( - ('start_date', 'end_date', 'time_trunc'), locals() + ('start_date', 'end_date', 'time_trunc', 'time_agg'), locals() ) request = http.Request('GET', self.get_url(), params) return request, parsers.parse_json @@ -28,6 +31,10 @@ def get(self, start_date, end_date): class ProfilePVPC(Indicator): pass +class DemandaDiariaElectricaPeninsularPrevista(Indicator): + path = 'indicators/460' + time_agg = 'average' + class ProfilePVPC20A(ProfilePVPC): path = 'indicators/526' @@ -224,6 +231,9 @@ class mhpPowerFactorControlFree(Indicator): class mhpPowerFactorControl(Indicator): path = 'indicators/1286' +class DemandaDiariaElectricaPeninsularReal(Indicator): + path = 'indicators/1293' + time_agg = 'average' class mhpEnergyBalanceFree(Indicator): path = 'indicators/1366' diff --git a/spec/indicators_spec.py b/spec/indicators_spec.py index c99649b..7fd900b 100644 --- a/spec/indicators_spec.py +++ b/spec/indicators_spec.py @@ -241,6 +241,21 @@ contain(u'Saldo horario neto de interconexión con Marruecos telemedidas') ) + with context('DemandaDiariaElectricaPeninsularPrevista'): + with it('Returns DemandaDiariaElectricaPeninsularPrevista instance'): + # 460 + e = Esios(self.token) + # Hourly case + profile = DemandaDiariaElectricaPeninsularPrevista(e) + assert isinstance(profile, DemandaDiariaElectricaPeninsularPrevista) + data = profile.get(self.start_date, self.end_date) + expect(data['indicator']['short_name']).to( + equal(u'Previsión diaria') + ) + expect(data['indicator']['name']).to( + contain(u'Previsión diaria de la demanda eléctrica peninsular') + ) + with context('PMDSNP'): with it('Returns pmd_snp instance'): # 573 @@ -771,6 +786,19 @@ expect(data['indicator']['name']).to( contain(u'Precio medio horario componente control factor potencia ') ) + with it('Returns DemandaDiariaElectricaPeninsularReal instance'): + # 1293 + e = Esios(self.token) + # Hourly case + profile = DemandaDiariaElectricaPeninsularReal(e) + assert isinstance(profile, DemandaDiariaElectricaPeninsularReal) + data = profile.get(self.start_date, self.end_date) + expect(data['indicator']['short_name']).to( + equal(u'Demanda real') + ) + expect(data['indicator']['name']).to( + contain(u'Demanda real') + ) with it('Returns mhpEnergyBalanceFree instance'): #1366 e = Esios(self.token)