Skip to content

Commit

Permalink
Update document.py (#1864)
Browse files Browse the repository at this point in the history
* 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

* add test case
  • Loading branch information
vvmruder authored Nov 27, 2023
1 parent 3c64ec9 commit 4a920ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
3 changes: 3 additions & 0 deletions tests/core/sources/test_document_oereblex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 4a920ad

Please sign in to comment.