refactor: Adapt to extended unit tests

This commit is contained in:
TrisNol 2023-10-15 13:21:41 +02:00
parent fd47487367
commit f1474feaf8
2 changed files with 12 additions and 14 deletions

View File

@ -503,18 +503,18 @@ def map_co_relation(data: dict) -> dict:
co_company_index = None co_company_index = None
for index, part in enumerate(parts): for index, part in enumerate(parts):
trimmed_part = part.strip() trimmed_part = part.strip()
result = re.findall(r"^c\/o (.*)$", trimmed_part) result = re.findall(r"^c\/o(.*)$", trimmed_part)
if len(result) == 1: if len(result) == 1:
co_company = result[0] co_company = result[0].strip()
co_company_index = index co_company_index = index
if co_company_index is not None: if co_company_index is not None:
del parts[co_company_index] del parts[co_company_index]
street = "".join(parts).strip() street = "".join(parts).strip()
data["location"].street = street data["location"].street = street
if co_company is not None: if co_company is not None and co_company != "":
relation = CompanyToCompanyRelationship( relation = CompanyToCompanyRelationship(
RelationshipRoleEnum.LOKATION_BEI, # type: ignore RelationshipRoleEnum.CARE_OF, # type: ignore
Location( Location(
data["location"].city, data["location"].city,
street, street,

View File

@ -723,7 +723,7 @@ def test_map_last_update() -> None:
"location": Location("", "Abc ffda", None, None), "location": Location("", "Abc ffda", None, None),
"relationships": [ "relationships": [
CompanyToCompanyRelationship( CompanyToCompanyRelationship(
RelationshipRoleEnum.LOKATION_BEI, # type: ignore RelationshipRoleEnum.CARE_OF, # type: ignore
Location("", "Abc ffda", None, None), Location("", "Abc ffda", None, None),
CompanyRelationshipEnum.COMPANY, CompanyRelationshipEnum.COMPANY,
"Youco24 Business Center", "Youco24 Business Center",
@ -734,7 +734,7 @@ def test_map_last_update() -> None:
( (
{ {
"location": Location( "location": Location(
"", "c/o Youco24 Business Center, Abc Str.", "42", "58644" "Iserlohn", "c/o Youco24 Business Center, Abc Str.", "42", "58644"
), ),
"relationships": [], "relationships": [],
}, },
@ -742,8 +742,8 @@ def test_map_last_update() -> None:
"location": Location("Iserlohn", "Abc Str.", "42", "58644"), "location": Location("Iserlohn", "Abc Str.", "42", "58644"),
"relationships": [ "relationships": [
CompanyToCompanyRelationship( CompanyToCompanyRelationship(
RelationshipRoleEnum.LOKATION_BEI, # type: ignore RelationshipRoleEnum.CARE_OF, # type: ignore
Location("Iserlohn", "Abc ffda", "42", "58644"), Location("Iserlohn", "Abc Str.", "42", "58644"),
CompanyRelationshipEnum.COMPANY, CompanyRelationshipEnum.COMPANY,
"Youco24 Business Center", "Youco24 Business Center",
) )
@ -753,7 +753,7 @@ def test_map_last_update() -> None:
( (
{ {
"location": Location( "location": Location(
"Iserlohn", "Abc Str. 42, c/o Youco24 Business Center", None, "58644" "Iserlohn", "Abc Str., c/o Youco24 Business Center", "42", "58644"
), ),
"relationships": [], "relationships": [],
}, },
@ -761,8 +761,8 @@ def test_map_last_update() -> None:
"location": Location("Iserlohn", "Abc Str.", "42", "58644"), "location": Location("Iserlohn", "Abc Str.", "42", "58644"),
"relationships": [ "relationships": [
CompanyToCompanyRelationship( CompanyToCompanyRelationship(
RelationshipRoleEnum.LOKATION_BEI, # type: ignore RelationshipRoleEnum.CARE_OF, # type: ignore
Location("Iserlohn", "Abc ffda", "42", "58644"), Location("Iserlohn", "Abc Str.", "42", "58644"),
CompanyRelationshipEnum.COMPANY, CompanyRelationshipEnum.COMPANY,
"Youco24 Business Center", "Youco24 Business Center",
) )
@ -771,9 +771,7 @@ def test_map_last_update() -> None:
), ),
( (
{ {
"location": Location( "location": Location("Iserlohn", "Abc Str., c/o", "42", "58644"),
"Iserlohn", "Abc Str. 42, c/o", None, "58644"
),
"relationships": [], "relationships": [],
}, },
{ {