From b97d2e5e86b0905e96a8b6e282865fe89d419a3a Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Fri, 8 Dec 2023 14:13:50 +0100 Subject: [PATCH 1/5] extensions for api 1.2.4 --- CHANGELOG | 3 +- geolink_formatter/parser.py | 3 + geolink_formatter/schema/v1.2.4.xsd | 166 ++++++++++++++++++ tests/resources/geolink_v1.2.4.xml | 45 +++++ .../resources/geolink_v1.2.4_error_status.xml | 45 +++++ tests/resources/prepublink_v1.2.4.xml | 51 ++++++ ...prepublink_v1.2.4_error_enactment_date.xml | 52 ++++++ tests/test_parser.py | 48 ++++- 8 files changed, 408 insertions(+), 5 deletions(-) create mode 100644 geolink_formatter/schema/v1.2.4.xsd create mode 100644 tests/resources/geolink_v1.2.4.xml create mode 100644 tests/resources/geolink_v1.2.4_error_status.xml create mode 100644 tests/resources/prepublink_v1.2.4.xml create mode 100644 tests/resources/prepublink_v1.2.4_error_enactment_date.xml diff --git a/CHANGELOG b/CHANGELOG index 79a942ab..27171677 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,9 +4,10 @@ Changelog 2.0.5 ----- -Supported GEO-Link API versions: v1.0.0, v1.1.0, v1.1.1, v1.2.0, v1.2.1, v1.2.2 (default), v1.2.3 +Supported GEO-Link API versions: v1.0.0, v1.1.0, v1.1.1, v1.2.0, v1.2.1, v1.2.2 (default), v1.2.3, v1.2.4 - Fix html rendering of documents with abrogation date +- Dependency updates 2.0.4 ----- diff --git a/geolink_formatter/parser.py b/geolink_formatter/parser.py index a1b93e65..dbc3446c 100644 --- a/geolink_formatter/parser.py +++ b/geolink_formatter/parser.py @@ -31,6 +31,9 @@ class SCHEMA(object): V1_2_3 = '1.2.3' """str: geoLink schema version 1.2.3""" + V1_2_4 = '1.2.4' + """str: geoLink schema version 1.2.3""" + class XML(object): diff --git a/geolink_formatter/schema/v1.2.4.xsd b/geolink_formatter/schema/v1.2.4.xsd new file mode 100644 index 00000000..2849c956 --- /dev/null +++ b/geolink_formatter/schema/v1.2.4.xsd @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/resources/geolink_v1.2.4.xml b/tests/resources/geolink_v1.2.4.xml new file mode 100644 index 00000000..084666a3 --- /dev/null +++ b/tests/resources/geolink_v1.2.4.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/resources/geolink_v1.2.4_error_status.xml b/tests/resources/geolink_v1.2.4_error_status.xml new file mode 100644 index 00000000..556ad7ee --- /dev/null +++ b/tests/resources/geolink_v1.2.4_error_status.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/resources/prepublink_v1.2.4.xml b/tests/resources/prepublink_v1.2.4.xml new file mode 100644 index 00000000..7c87709b --- /dev/null +++ b/tests/resources/prepublink_v1.2.4.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/resources/prepublink_v1.2.4_error_enactment_date.xml b/tests/resources/prepublink_v1.2.4_error_enactment_date.xml new file mode 100644 index 00000000..a28303b2 --- /dev/null +++ b/tests/resources/prepublink_v1.2.4_error_enactment_date.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/test_parser.py b/tests/test_parser.py index e5203fbe..7431b629 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -263,7 +263,7 @@ def test_schema_version_1_2_3(): with requests_mock.mock() as m: with open('tests/resources/geolink_v1.2.3.xml', 'rb') as f: m.get('http://oereblex.test.com/api/geolinks/1500.xml', content=f.read()) - documents = XML(version=SCHEMA.V1_2_2).from_url('http://oereblex.test.com/api/geolinks/1500.xml') + documents = XML(version=SCHEMA.V1_2_3).from_url('http://oereblex.test.com/api/geolinks/1500.xml') assert len(documents) == 5 assert documents[0].index is None assert documents[-3].index == 1 @@ -275,7 +275,7 @@ def test_schema_version_1_2_3_prepublink(): with requests_mock.mock() as m: with open('tests/resources/prepublink_v1.2.3.xml', 'rb') as f: m.get('http://oereblex.test.com/api/geolinks/1500.xml', content=f.read()) - documents = XML(version=SCHEMA.V1_2_2).from_url('http://oereblex.test.com/api/geolinks/1500.xml') + documents = XML(version=SCHEMA.V1_2_3).from_url('http://oereblex.test.com/api/geolinks/1500.xml') assert len(documents) == 6 assert documents[0].index is None assert documents[-3].index == 1 @@ -288,7 +288,7 @@ def test_schema_version_1_2_3_faulty_prepublink(): with requests_mock.mock() as m: with open('tests/resources/prepublink_v1.2.3_error_enactment_date.xml', 'rb') as f: m.get('http://oereblex.test.com/api/geolinks/1500.xml', content=f.read()) - XML(version=SCHEMA.V1_2_2).from_url('http://oereblex.test.com/api/geolinks/1500.xml') + XML(version=SCHEMA.V1_2_3).from_url('http://oereblex.test.com/api/geolinks/1500.xml') def test_schema_version_1_2_3_faulty_geolink(): @@ -296,7 +296,47 @@ def test_schema_version_1_2_3_faulty_geolink(): with requests_mock.mock() as m: with open('tests/resources/geolink_v1.2.3_error_status.xml', 'rb') as f: m.get('http://oereblex.test.com/api/geolinks/1500.xml', content=f.read()) - XML(version=SCHEMA.V1_2_2).from_url('http://oereblex.test.com/api/geolinks/1500.xml') + XML(version=SCHEMA.V1_2_3).from_url('http://oereblex.test.com/api/geolinks/1500.xml') + + +def test_schema_version_1_2_4(): + with requests_mock.mock() as m: + with open('tests/resources/geolink_v1.2.4.xml', 'rb') as f: + m.get('http://oereblex.test.com/api/geolinks/1500.xml', content=f.read()) + documents = XML(version=SCHEMA.V1_2_4).from_url('http://oereblex.test.com/api/geolinks/1500.xml') + assert len(documents) == 5 + assert documents[0].index is None + assert documents[-3].index == 1 + assert documents[-2].index == 2 + assert documents[-1].index == 3 + + +def test_schema_version_1_2_4_prepublink(): + with requests_mock.mock() as m: + with open('tests/resources/prepublink_v1.2.4.xml', 'rb') as f: + m.get('http://oereblex.test.com/api/geolinks/1500.xml', content=f.read()) + documents = XML(version=SCHEMA.V1_2_4).from_url('http://oereblex.test.com/api/geolinks/1500.xml') + assert len(documents) == 6 + assert documents[0].index is None + assert documents[-3].index == 1 + assert documents[-2].index == 2 + assert documents[-1].index == 3 + + +def test_schema_version_1_2_4_faulty_prepublink(): + with pytest.raises(xmlschema.XMLSchemaValidationError): + with requests_mock.mock() as m: + with open('tests/resources/prepublink_v1.2.4_error_enactment_date.xml', 'rb') as f: + m.get('http://oereblex.test.com/api/geolinks/1500.xml', content=f.read()) + XML(version=SCHEMA.V1_2_4).from_url('http://oereblex.test.com/api/geolinks/1500.xml') + + +def test_schema_version_1_2_4_faulty_geolink(): + with pytest.raises(xmlschema.XMLSchemaValidationError): + with requests_mock.mock() as m: + with open('tests/resources/geolink_v1.2.4_error_status.xml', 'rb') as f: + m.get('http://oereblex.test.com/api/geolinks/1500.xml', content=f.read()) + XML(version=SCHEMA.V1_2_4).from_url('http://oereblex.test.com/api/geolinks/1500.xml') def test_default_version_with_locale(): From dbb73df6348416960fe4e5edc22d8cfe4626a2f9 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Mon, 11 Dec 2023 11:09:00 +0100 Subject: [PATCH 2/5] set default to 1.2.4 --- CHANGELOG | 2 +- geolink_formatter/parser.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 27171677..9b572e0d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,7 +4,7 @@ Changelog 2.0.5 ----- -Supported GEO-Link API versions: v1.0.0, v1.1.0, v1.1.1, v1.2.0, v1.2.1, v1.2.2 (default), v1.2.3, v1.2.4 +Supported GEO-Link API versions: v1.0.0, v1.1.0, v1.1.1, v1.2.0, v1.2.1, v1.2.2, v1.2.3, v1.2.4 (default) - Fix html rendering of documents with abrogation date - Dependency updates diff --git a/geolink_formatter/parser.py b/geolink_formatter/parser.py index dbc3446c..d11b763e 100644 --- a/geolink_formatter/parser.py +++ b/geolink_formatter/parser.py @@ -40,7 +40,7 @@ class XML(object): _date_format = '%Y-%m-%d' """str: Format of date values in XML.""" - def __init__(self, host_url=None, version='1.2.2', dtd_validation=False, xsd_validation=True): + def __init__(self, host_url=None, version='1.2.4', dtd_validation=False, xsd_validation=True): """Create a new XML parser instance containing the geoLink XSD for validation. Args: From 551f3ea07867b36e05ea077972a55f4b83bad15d Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Mon, 8 Jan 2024 09:44:03 +0100 Subject: [PATCH 3/5] add .codacy.yaml --- .codacy.yaml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .codacy.yaml diff --git a/.codacy.yaml b/.codacy.yaml new file mode 100644 index 00000000..637bd132 --- /dev/null +++ b/.codacy.yaml @@ -0,0 +1,4 @@ +--- +engines: + pylintpython3: + max-line-length: 110 From ef0f567c5b182ee170d9c93326bb1f208cf0d737 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Mon, 8 Jan 2024 10:29:28 +0100 Subject: [PATCH 4/5] update --- .codacy.yaml | 5 +++-- .pylintrc | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .pylintrc diff --git a/.codacy.yaml b/.codacy.yaml index 637bd132..7fbdb5d6 100644 --- a/.codacy.yaml +++ b/.codacy.yaml @@ -1,4 +1,5 @@ --- engines: - pylintpython3: - max-line-length: 110 + pylint: + enabled: true + python_version: 3 diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 00000000..ba7ab9aa --- /dev/null +++ b/.pylintrc @@ -0,0 +1,4 @@ +[FORMAT] + +# Maximum number of characters on a single line. +max-line-length=100 From 6a88d3157edab2dd35f4560eb1950a8f275e3beb Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Mon, 8 Jan 2024 10:44:12 +0100 Subject: [PATCH 5/5] update --- .codacy.yaml | 2 +- .pylintrc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.codacy.yaml b/.codacy.yaml index 7fbdb5d6..4758da52 100644 --- a/.codacy.yaml +++ b/.codacy.yaml @@ -1,5 +1,5 @@ --- engines: - pylint: + pylintpython3: enabled: true python_version: 3 diff --git a/.pylintrc b/.pylintrc index ba7ab9aa..3539e9a8 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,4 +1,4 @@ [FORMAT] # Maximum number of characters on a single line. -max-line-length=100 +max-line-length=110