From a66b9929010e7cb5c65eaa51d574bff49ba20def Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emili=20Garc=C3=ADa?= Date: Tue, 12 Dec 2023 10:35:12 +0100 Subject: [PATCH] Enables headers on parser --- esios/archives.py | 2 +- esios/parsers.py | 2 +- spec/archives_spec.py | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/esios/archives.py b/esios/archives.py index 58b9df1..2478895 100644 --- a/esios/archives.py +++ b/esios/archives.py @@ -15,7 +15,7 @@ def parser_none(body, code, headers): - return body + return body, headers class Archive(base.RESTResource): diff --git a/esios/parsers.py b/esios/parsers.py index 119c570..9be789a 100644 --- a/esios/parsers.py +++ b/esios/parsers.py @@ -41,7 +41,7 @@ def config_validators(self, pos): self.provisional_parser = objectify.makeparser(schema=xmlschema) def get_data_json(self, program_unit, start, end): - res = self.download(start, end) + res, headers = self.download(start, end) return self.parse_to_json(res, program_unit) def get_data_json_from_file(self, program_unit, filepath): diff --git a/spec/archives_spec.py b/spec/archives_spec.py index 0f9f98d..1e57a99 100644 --- a/spec/archives_spec.py +++ b/spec/archives_spec.py @@ -18,7 +18,7 @@ def test_expected_to_work(the_class, start, end, expected_versions, next=0): """ General expected to work method """ - res = the_class().download(start, end, next=next) + res, headers = the_class().download(start, end, next=next) c = BytesIO(res) zf = zipfile.ZipFile(c) @@ -33,7 +33,7 @@ def test_expected_to_break(the_class, start, end, assert_message, next=0): """ it_works = True try: - res = the_class().download(start, end, next=next) + res, headers = the_class().download(start, end, next=next) except: it_works = False @@ -264,7 +264,7 @@ def validate_P48cierre(xml): start = today.replace(hour=0, minute=0, second=0, microsecond=0) - relativedelta.relativedelta(days=1) end = today.replace(hour=23, minute=59, second=59, microsecond=0) - relativedelta.relativedelta(days=1) - res = P48Cierre(self.e).download(start, end) + res, headers = P48Cierre(self.e).download(start, end) assert validate_P48cierre(res) assert not validate_P48cierre(res + b'ERROR') @@ -274,7 +274,7 @@ def validate_P48cierre(xml): start = today.replace(hour=0, minute=0, second=0, microsecond=0) - relativedelta.relativedelta(days=1) end = today.replace(hour=23, minute=59, second=59, microsecond=0) - res = P48Cierre(self.e).download(start, end) + res, headers = P48Cierre(self.e).download(start, end) c = BytesIO(res) zf = zipfile.ZipFile(c) @@ -298,7 +298,7 @@ def validate_P48cierre(xml): last_month_day = calendar.monthrange(today.year, today.month)[1] end = datetime(today.year, today.month, today.day > 1 and today.day - 1 or 1) - res = P48Cierre(self.e).download(start, end) + res, headers = P48Cierre(self.e).download(start, end) c = BytesIO(res) zf = zipfile.ZipFile(c)