mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-04-25 02:42:33 +02:00
test(data-extraction): Host temporary_dir in local env
This commit is contained in:
parent
535c31fc9f
commit
e6af96ea6d
@ -24,7 +24,7 @@ from aki_prj23_transparenzregister.utils.data_extraction.unternehmensregister im
|
|||||||
|
|
||||||
|
|
||||||
def test_transform_xml_to_json() -> None:
|
def test_transform_xml_to_json() -> None:
|
||||||
with TemporaryDirectory() as temp_source_dir:
|
with TemporaryDirectory(dir="./") as temp_source_dir:
|
||||||
with open(os.path.join(temp_source_dir, "test.xml"), "w") as file:
|
with open(os.path.join(temp_source_dir, "test.xml"), "w") as file:
|
||||||
xml_input = """<?xml version="1.0" encoding="UTF-8"?>
|
xml_input = """<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<test>
|
<test>
|
||||||
@ -32,7 +32,7 @@ def test_transform_xml_to_json() -> None:
|
|||||||
</test>
|
</test>
|
||||||
"""
|
"""
|
||||||
file.write(xml_input)
|
file.write(xml_input)
|
||||||
with TemporaryDirectory() as temp_target_dir:
|
with TemporaryDirectory(dir="./") as temp_target_dir:
|
||||||
transform.transform_xml_to_json(temp_source_dir, temp_target_dir)
|
transform.transform_xml_to_json(temp_source_dir, temp_target_dir)
|
||||||
with open(os.path.join(temp_target_dir, "test.json")) as file:
|
with open(os.path.join(temp_target_dir, "test.json")) as file:
|
||||||
json_output = json.load(file)
|
json_output = json.load(file)
|
||||||
@ -50,7 +50,7 @@ def test_parse_stakeholder_org_hidden_in_person() -> None:
|
|||||||
"Rolle": {"Rollenbezeichnung": {"content": "Kommanditist(in)"}},
|
"Rolle": {"Rollenbezeichnung": {"content": "Kommanditist(in)"}},
|
||||||
}
|
}
|
||||||
expected_result = CompanyToCompanyRelationship(
|
expected_result = CompanyToCompanyRelationship(
|
||||||
role=RelationshipRoleEnum.KOMMANDITIST, # type: ignore
|
role=RelationshipRoleEnum.KOMMANDITIST,
|
||||||
description="Some Company KG",
|
description="Some Company KG",
|
||||||
type=CompanyRelationshipEnum.COMPANY,
|
type=CompanyRelationshipEnum.COMPANY,
|
||||||
location=Location(**{"city": "Area 51"}),
|
location=Location(**{"city": "Area 51"}),
|
||||||
@ -70,7 +70,7 @@ def test_parse_stakeholder_person() -> None:
|
|||||||
"Rolle": {"Rollenbezeichnung": {"content": "Geschäftsleiter(in)"}},
|
"Rolle": {"Rollenbezeichnung": {"content": "Geschäftsleiter(in)"}},
|
||||||
}
|
}
|
||||||
expected_result = PersonToCompanyRelationship(
|
expected_result = PersonToCompanyRelationship(
|
||||||
role=RelationshipRoleEnum.GESCHAEFTSLEITER, # type: ignore
|
role=RelationshipRoleEnum.GESCHAEFTSLEITER,
|
||||||
date_of_birth="1947-09-21",
|
date_of_birth="1947-09-21",
|
||||||
name=PersonName(**{"firstname": "Stephen", "lastname": "King"}),
|
name=PersonName(**{"firstname": "Stephen", "lastname": "King"}),
|
||||||
type=CompanyRelationshipEnum.PERSON,
|
type=CompanyRelationshipEnum.PERSON,
|
||||||
@ -97,7 +97,7 @@ def test_parse_stakeholder_org() -> None:
|
|||||||
}
|
}
|
||||||
expected_result = CompanyToCompanyRelationship(
|
expected_result = CompanyToCompanyRelationship(
|
||||||
description="Transparenzregister kG",
|
description="Transparenzregister kG",
|
||||||
role=RelationshipRoleEnum.DIREKTOR, # type: ignore
|
role=RelationshipRoleEnum.DIREKTOR,
|
||||||
type=CompanyRelationshipEnum.COMPANY,
|
type=CompanyRelationshipEnum.COMPANY,
|
||||||
location=Location(
|
location=Location(
|
||||||
**{
|
**{
|
||||||
@ -218,7 +218,7 @@ def test_map_rechtsform_from_name() -> None:
|
|||||||
|
|
||||||
def test_map_capital_kg_single() -> None:
|
def test_map_capital_kg_single() -> None:
|
||||||
capital = Capital(
|
capital = Capital(
|
||||||
currency=CurrencyEnum.EURO, value=69000, type=CapitalTypeEnum.HAFTEINLAGE # type: ignore
|
currency=CurrencyEnum.EURO, value=69000, type=CapitalTypeEnum.HAFTEINLAGE
|
||||||
)
|
)
|
||||||
data = {
|
data = {
|
||||||
"XJustiz_Daten": {
|
"XJustiz_Daten": {
|
||||||
@ -239,13 +239,13 @@ def test_map_capital_kg_single() -> None:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = transform.map_capital(data, CompanyTypeEnum.KG) # type: ignore
|
result = transform.map_capital(data, CompanyTypeEnum.KG)
|
||||||
assert result == capital
|
assert result == capital
|
||||||
|
|
||||||
|
|
||||||
def test_map_capital_kg_sum() -> None:
|
def test_map_capital_kg_sum() -> None:
|
||||||
capital = Capital(
|
capital = Capital(
|
||||||
currency=CurrencyEnum.EURO, value=20000, type=CapitalTypeEnum.HAFTEINLAGE # type: ignore
|
currency=CurrencyEnum.EURO, value=20000, type=CapitalTypeEnum.HAFTEINLAGE
|
||||||
)
|
)
|
||||||
data = {
|
data = {
|
||||||
"XJustiz_Daten": {
|
"XJustiz_Daten": {
|
||||||
@ -274,20 +274,20 @@ def test_map_capital_kg_sum() -> None:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = transform.map_capital(data, CompanyTypeEnum.KG) # type: ignore
|
result = transform.map_capital(data, CompanyTypeEnum.KG)
|
||||||
assert result == capital
|
assert result == capital
|
||||||
|
|
||||||
|
|
||||||
def test_map_capital_no_fachdaten() -> None:
|
def test_map_capital_no_fachdaten() -> None:
|
||||||
data = {"XJustiz_Daten": {"Fachdaten_Register": {}}} # type: ignore
|
data: dict = {"XJustiz_Daten": {"Fachdaten_Register": {}}}
|
||||||
|
|
||||||
result = transform.map_capital(data, CompanyTypeEnum.KG) # type: ignore
|
result = transform.map_capital(data, CompanyTypeEnum.KG)
|
||||||
assert result is None
|
assert result is None
|
||||||
|
|
||||||
|
|
||||||
def test_map_capital_gmbh() -> None:
|
def test_map_capital_gmbh() -> None:
|
||||||
capital = Capital(
|
capital = Capital(
|
||||||
currency=CurrencyEnum.DEUTSCHE_MARK, value=42, type=CapitalTypeEnum.STAMMKAPITAL # type: ignore
|
currency=CurrencyEnum.DEUTSCHE_MARK, value=42, type=CapitalTypeEnum.STAMMKAPITAL
|
||||||
)
|
)
|
||||||
data = {
|
data = {
|
||||||
"XJustiz_Daten": {
|
"XJustiz_Daten": {
|
||||||
@ -306,13 +306,13 @@ def test_map_capital_gmbh() -> None:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = transform.map_capital(data, CompanyTypeEnum.GMBH) # type: ignore
|
result = transform.map_capital(data, CompanyTypeEnum.GMBH)
|
||||||
assert result == capital
|
assert result == capital
|
||||||
|
|
||||||
|
|
||||||
def test_map_capital_ag() -> None:
|
def test_map_capital_ag() -> None:
|
||||||
capital = Capital(
|
capital = Capital(
|
||||||
currency=CurrencyEnum.DEUTSCHE_MARK, value=42, type=CapitalTypeEnum.GRUNDKAPITAL # type: ignore
|
currency=CurrencyEnum.DEUTSCHE_MARK, value=42, type=CapitalTypeEnum.GRUNDKAPITAL
|
||||||
)
|
)
|
||||||
data = {
|
data = {
|
||||||
"XJustiz_Daten": {
|
"XJustiz_Daten": {
|
||||||
@ -333,13 +333,13 @@ def test_map_capital_ag() -> None:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = transform.map_capital(data, CompanyTypeEnum.SE) # type: ignore
|
result = transform.map_capital(data, CompanyTypeEnum.SE)
|
||||||
assert result == capital
|
assert result == capital
|
||||||
|
|
||||||
|
|
||||||
def test_map_capital_personengesellschaft() -> None:
|
def test_map_capital_personengesellschaft() -> None:
|
||||||
capital = Capital(
|
capital = Capital(
|
||||||
currency=CurrencyEnum.DEUTSCHE_MARK, value=42, type=CapitalTypeEnum.STAMMKAPITAL # type: ignore
|
currency=CurrencyEnum.DEUTSCHE_MARK, value=42, type=CapitalTypeEnum.STAMMKAPITAL
|
||||||
)
|
)
|
||||||
data = {
|
data = {
|
||||||
"XJustiz_Daten": {
|
"XJustiz_Daten": {
|
||||||
@ -358,13 +358,13 @@ def test_map_capital_personengesellschaft() -> None:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = transform.map_capital(data, CompanyTypeEnum.OHG) # type: ignore
|
result = transform.map_capital(data, CompanyTypeEnum.OHG)
|
||||||
assert result == capital
|
assert result == capital
|
||||||
|
|
||||||
|
|
||||||
def test_map_capital_einzelkaufmann() -> None:
|
def test_map_capital_einzelkaufmann() -> None:
|
||||||
capital = Capital(
|
capital = Capital(
|
||||||
currency=CurrencyEnum.DEUTSCHE_MARK, value=42, type=CapitalTypeEnum.STAMMKAPITAL # type: ignore
|
currency=CurrencyEnum.DEUTSCHE_MARK, value=42, type=CapitalTypeEnum.STAMMKAPITAL
|
||||||
)
|
)
|
||||||
data = {
|
data = {
|
||||||
"XJustiz_Daten": {
|
"XJustiz_Daten": {
|
||||||
@ -383,13 +383,13 @@ def test_map_capital_einzelkaufmann() -> None:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = transform.map_capital(data, CompanyTypeEnum.EINZELKAUFMANN) # type: ignore
|
result = transform.map_capital(data, CompanyTypeEnum.EINZELKAUFMANN)
|
||||||
assert result is None
|
assert result is None
|
||||||
|
|
||||||
|
|
||||||
def test_map_capital_partial_null_values() -> None:
|
def test_map_capital_partial_null_values() -> None:
|
||||||
capital = Capital(
|
capital = Capital(
|
||||||
currency=CurrencyEnum.DEUTSCHE_MARK, value=42, type=CapitalTypeEnum.STAMMKAPITAL # type: ignore
|
currency=CurrencyEnum.DEUTSCHE_MARK, value=42, type=CapitalTypeEnum.STAMMKAPITAL
|
||||||
)
|
)
|
||||||
data = {
|
data = {
|
||||||
"XJustiz_Daten": {
|
"XJustiz_Daten": {
|
||||||
@ -408,7 +408,7 @@ def test_map_capital_partial_null_values() -> None:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = transform.map_capital(data, CompanyTypeEnum.OHG) # type: ignore
|
result = transform.map_capital(data, CompanyTypeEnum.OHG)
|
||||||
assert result is None
|
assert result is None
|
||||||
|
|
||||||
|
|
||||||
@ -573,7 +573,7 @@ def test_map_unternehmensregister_json( # noqa: PLR0913
|
|||||||
) -> None:
|
) -> None:
|
||||||
expected_result = Company(
|
expected_result = Company(
|
||||||
**{
|
**{
|
||||||
"id": Mock(), # type: ignore
|
"id": Mock(),
|
||||||
"name": Mock(),
|
"name": Mock(),
|
||||||
"location": Mock(),
|
"location": Mock(),
|
||||||
"last_update": Mock(),
|
"last_update": Mock(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user