From 5317f027b87429e05cb57e03ffe9e00b45c6c194 Mon Sep 17 00:00:00 2001 From: vvmruder Date: Mon, 27 Nov 2023 11:16:31 +0100 Subject: [PATCH 1/2] Update document.py Fix broken interface. If the URL is None we won't need a multilingual dict like {"de": None} but a real None. This PR is solving the issue --- .../contrib/data_sources/oereblex/sources/document.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pyramid_oereb/contrib/data_sources/oereblex/sources/document.py b/pyramid_oereb/contrib/data_sources/oereblex/sources/document.py index e0bbe8acf7..4bf1a25084 100644 --- a/pyramid_oereb/contrib/data_sources/oereblex/sources/document.py +++ b/pyramid_oereb/contrib/data_sources/oereblex/sources/document.py @@ -199,12 +199,16 @@ def _get_document_records(self, document, language): raise AssertionError('Missing authority for document #{0}'.format(document.id)) if oereblex_doctype is None: raise AssertionError('Missing type for document #{0}'.format(document.id)) + if document.authority_url is None: + authority_url = None + else: + authority_url = {language: document.authority_url} # Get document type document_type = Config.get_document_type_by_data_code(self._code, oereblex_doctype) # Create related office record - office = OfficeRecord({language: authority}, office_at_web={language: document.authority_url}) + office = OfficeRecord({language: authority}, office_at_web=authority_url) # Get files records = [] From 567c77cc19f9142bdff494cf285c1dd4de0f42b3 Mon Sep 17 00:00:00 2001 From: Clemens Rudert Date: Mon, 27 Nov 2023 11:26:44 +0100 Subject: [PATCH 2/2] add test case --- tests/core/sources/test_document_oereblex.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/core/sources/test_document_oereblex.py b/tests/core/sources/test_document_oereblex.py index 02abc3b9a1..ae187c1d78 100644 --- a/tests/core/sources/test_document_oereblex.py +++ b/tests/core/sources/test_document_oereblex.py @@ -297,6 +297,9 @@ def test_read_related_notice_as_main(oereblex_test_config): assert isinstance(document.responsible_office, OfficeRecord) assert document.responsible_office.name == {'de': '-'} assert document.responsible_office.office_at_web is None + assert source.records[0].responsible_office.office_at_web == { + 'de': "http%3A%2F%2Fwww.zihlschlacht-sitterdorf.ch" + } assert document.published_from == datetime.date(1970, 1, 1) assert document.index == 40