mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-05-14 02:58:45 +02:00
fix(data-extraction): Handle malformed date_of_birth fields (#204)
fix(data-extraction): Handle malformed date_of_birth fields
This commit is contained in:
commit
f65a377d73
@ -124,7 +124,7 @@ class PersonToCompanyRelationship(CompanyRelationship):
|
|||||||
"""Extension of CompanyRelationship with extras for Person."""
|
"""Extension of CompanyRelationship with extras for Person."""
|
||||||
|
|
||||||
name: PersonName
|
name: PersonName
|
||||||
date_of_birth: str
|
date_of_birth: str | None
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -395,19 +395,13 @@ def add_person_relation(person: dict[str, Any], company_id: int, db: Session) ->
|
|||||||
db=db,
|
db=db,
|
||||||
)
|
)
|
||||||
except DataInvalidError:
|
except DataInvalidError:
|
||||||
# logger.exception("Test except: ")
|
|
||||||
if date_of_brith:
|
if date_of_brith:
|
||||||
# print("Break")
|
|
||||||
raise
|
raise
|
||||||
# TODO enable the following line
|
logger.debug(
|
||||||
# logger.warning(f"No date of birth birth for {name['firstname']} {name['lastname']}")
|
f"No date of birth birth for {person['name']['lastname']}, {person['name']['firstname']}"
|
||||||
|
)
|
||||||
db.rollback()
|
db.rollback()
|
||||||
return
|
return
|
||||||
except TypeError as error:
|
|
||||||
# TODO remove unhashable type catcher
|
|
||||||
if "unhashable type: 'dict'" in str(error):
|
|
||||||
return
|
|
||||||
raise
|
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception("Test except")
|
logger.exception("Test except")
|
||||||
raise
|
raise
|
||||||
|
@ -82,6 +82,27 @@ def test_parse_stakeholder_person() -> None:
|
|||||||
assert transform.parse_stakeholder(data) == expected_result
|
assert transform.parse_stakeholder(data) == expected_result
|
||||||
|
|
||||||
|
|
||||||
|
def test_parse_stakeholder_person_missing_date_of_birth() -> None:
|
||||||
|
data = {
|
||||||
|
"Beteiligter": {
|
||||||
|
"Natuerliche_Person": {
|
||||||
|
"Voller_Name": {"Vorname": "Stephen", "Nachname": "King"},
|
||||||
|
"Anschrift": {"Ort": "Maine"},
|
||||||
|
"Geburt": {"Geburtsdatum": {"@xsi:nil": "true"}},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Rolle": {"Rollenbezeichnung": {"content": "Geschäftsleiter(in)"}},
|
||||||
|
}
|
||||||
|
expected_result = PersonToCompanyRelationship(
|
||||||
|
role=RelationshipRoleEnum.GESCHAEFTSLEITER, # type: ignore
|
||||||
|
date_of_birth=None,
|
||||||
|
name=PersonName(**{"firstname": "Stephen", "lastname": "King"}),
|
||||||
|
type=CompanyRelationshipEnum.PERSON,
|
||||||
|
location=Location(**{"city": "Maine"}),
|
||||||
|
)
|
||||||
|
assert transform.parse_stakeholder(data) == expected_result
|
||||||
|
|
||||||
|
|
||||||
def test_parse_stakeholder_org() -> None:
|
def test_parse_stakeholder_org() -> None:
|
||||||
data = {
|
data = {
|
||||||
"Beteiligter": {
|
"Beteiligter": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user