mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-06-22 07:53:55 +02:00
ignore types mypy
This commit is contained in:
@ -60,6 +60,14 @@ class DistrictCourt:
|
|||||||
name: str
|
name: str
|
||||||
city: str
|
city: str
|
||||||
|
|
||||||
|
def to_dict(self) -> dict:
|
||||||
|
"""Transform to dict.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: Dictionary
|
||||||
|
"""
|
||||||
|
return asdict(self)
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class CompanyID:
|
class CompanyID:
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""Transform raw Unternehmensregister export (*.xml) to processed .json files for loading."""
|
"""Transform raw Unternehmensregister export (*.xml) to processed .json files for loading."""
|
||||||
# mypy: ignore-errors
|
|
||||||
import dataclasses
|
import dataclasses
|
||||||
import glob
|
import glob
|
||||||
import json
|
import json
|
||||||
|
@ -3,19 +3,26 @@
|
|||||||
|
|
||||||
from aki_prj23_transparenzregister.models.company import (
|
from aki_prj23_transparenzregister.models.company import (
|
||||||
Capital,
|
Capital,
|
||||||
|
CapitalTypeEnum,
|
||||||
Company,
|
Company,
|
||||||
CompanyID,
|
CompanyID,
|
||||||
|
CompanyTypeEnum,
|
||||||
|
CurrencyEnum,
|
||||||
|
DistrictCourt,
|
||||||
Location,
|
Location,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_to_dict() -> None:
|
def test_to_dict() -> None:
|
||||||
"""Tests if the version tag is entered."""
|
"""Tests if the version tag is entered."""
|
||||||
company_id = CompanyID("The Shire", "420")
|
district_court = DistrictCourt("abc", "abc")
|
||||||
|
company_id = CompanyID(district_court=district_court, hr_number="HRB 123")
|
||||||
location = Location(
|
location = Location(
|
||||||
city="Insmouth", house_number="19", street="Harbor", zip_code="1890"
|
city="Insmouth", house_number="19", street="Harbor", zip_code="1890"
|
||||||
)
|
)
|
||||||
capital = Capital(currency="BTC", type="Virtual assets", value=42)
|
capital = Capital(
|
||||||
|
currency=CurrencyEnum.DEUTSCHE_MARK, type=CapitalTypeEnum.GRUNDKAPITAL, value=42 # type: ignore
|
||||||
|
)
|
||||||
company = Company(
|
company = Company(
|
||||||
id=company_id,
|
id=company_id,
|
||||||
last_update="Tomorrow",
|
last_update="Tomorrow",
|
||||||
@ -24,13 +31,13 @@ def test_to_dict() -> None:
|
|||||||
relationships=[],
|
relationships=[],
|
||||||
business_purpose="Blockchain and NFTs",
|
business_purpose="Blockchain and NFTs",
|
||||||
capital=capital,
|
capital=capital,
|
||||||
company_type="Something",
|
company_type=CompanyTypeEnum.AG, # type: ignore
|
||||||
founding_date="Yesterday",
|
founding_date="Yesterday",
|
||||||
)
|
)
|
||||||
|
|
||||||
assert company.to_dict() == {
|
assert company.to_dict() == {
|
||||||
"id": {
|
"id": {
|
||||||
"district_court": company_id.district_court,
|
"district_court": district_court.to_dict(),
|
||||||
"hr_number": company_id.hr_number,
|
"hr_number": company_id.hr_number,
|
||||||
},
|
},
|
||||||
"last_update": company.last_update,
|
"last_update": company.last_update,
|
||||||
@ -48,6 +55,6 @@ def test_to_dict() -> None:
|
|||||||
"currency": capital.currency,
|
"currency": capital.currency,
|
||||||
"type": capital.type,
|
"type": capital.type,
|
||||||
},
|
},
|
||||||
"company_type": "Something",
|
"company_type": company.company_type,
|
||||||
"founding_date": "Yesterday",
|
"founding_date": "Yesterday",
|
||||||
}
|
}
|
||||||
|
@ -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,
|
role=RelationshipRoleEnum.KOMMANDITIST, # type: ignore
|
||||||
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,
|
role=RelationshipRoleEnum.GESCHAEFTSLEITER, # type: ignore
|
||||||
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,
|
role=RelationshipRoleEnum.DIREKTOR, # type: ignore
|
||||||
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
|
currency=CurrencyEnum.EURO, value=69000, type=CapitalTypeEnum.HAFTEINLAGE # type: ignore
|
||||||
)
|
)
|
||||||
data = {
|
data = {
|
||||||
"XJustiz_Daten": {
|
"XJustiz_Daten": {
|
||||||
@ -239,13 +239,13 @@ def test_map_capital_kg_single() -> None:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = transform.map_capital(data, CompanyTypeEnum.KG)
|
result = transform.map_capital(data, CompanyTypeEnum.KG) # type: ignore
|
||||||
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
|
currency=CurrencyEnum.EURO, value=20000, type=CapitalTypeEnum.HAFTEINLAGE # type: ignore
|
||||||
)
|
)
|
||||||
data = {
|
data = {
|
||||||
"XJustiz_Daten": {
|
"XJustiz_Daten": {
|
||||||
@ -274,20 +274,20 @@ def test_map_capital_kg_sum() -> None:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = transform.map_capital(data, CompanyTypeEnum.KG)
|
result = transform.map_capital(data, CompanyTypeEnum.KG) # type: ignore
|
||||||
assert result == capital
|
assert result == capital
|
||||||
|
|
||||||
|
|
||||||
def test_map_capital_no_fachdaten() -> None:
|
def test_map_capital_no_fachdaten() -> None:
|
||||||
data: dict = {"XJustiz_Daten": {"Fachdaten_Register": {}}}
|
data: dict = {"XJustiz_Daten": {"Fachdaten_Register": {}}}
|
||||||
|
|
||||||
result = transform.map_capital(data, CompanyTypeEnum.KG)
|
result = transform.map_capital(data, CompanyTypeEnum.KG) # type: ignore
|
||||||
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
|
currency=CurrencyEnum.DEUTSCHE_MARK, value=42, type=CapitalTypeEnum.STAMMKAPITAL # type: ignore
|
||||||
)
|
)
|
||||||
data = {
|
data = {
|
||||||
"XJustiz_Daten": {
|
"XJustiz_Daten": {
|
||||||
@ -306,13 +306,13 @@ def test_map_capital_gmbh() -> None:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = transform.map_capital(data, CompanyTypeEnum.GMBH)
|
result = transform.map_capital(data, CompanyTypeEnum.GMBH) # type: ignore
|
||||||
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
|
currency=CurrencyEnum.DEUTSCHE_MARK, value=42, type=CapitalTypeEnum.GRUNDKAPITAL # type: ignore
|
||||||
)
|
)
|
||||||
data = {
|
data = {
|
||||||
"XJustiz_Daten": {
|
"XJustiz_Daten": {
|
||||||
@ -333,13 +333,13 @@ def test_map_capital_ag() -> None:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = transform.map_capital(data, CompanyTypeEnum.SE)
|
result = transform.map_capital(data, CompanyTypeEnum.SE) # type: ignore
|
||||||
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
|
currency=CurrencyEnum.DEUTSCHE_MARK, value=42, type=CapitalTypeEnum.STAMMKAPITAL # type: ignore
|
||||||
)
|
)
|
||||||
data = {
|
data = {
|
||||||
"XJustiz_Daten": {
|
"XJustiz_Daten": {
|
||||||
@ -358,13 +358,13 @@ def test_map_capital_personengesellschaft() -> None:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = transform.map_capital(data, CompanyTypeEnum.OHG)
|
result = transform.map_capital(data, CompanyTypeEnum.OHG) # type: ignore
|
||||||
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
|
currency=CurrencyEnum.DEUTSCHE_MARK, value=42, type=CapitalTypeEnum.STAMMKAPITAL # type: ignore
|
||||||
)
|
)
|
||||||
data = {
|
data = {
|
||||||
"XJustiz_Daten": {
|
"XJustiz_Daten": {
|
||||||
@ -383,13 +383,13 @@ def test_map_capital_einzelkaufmann() -> None:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = transform.map_capital(data, CompanyTypeEnum.EINZELKAUFMANN)
|
result = transform.map_capital(data, CompanyTypeEnum.EINZELKAUFMANN) # type: ignore
|
||||||
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
|
currency=CurrencyEnum.DEUTSCHE_MARK, value=42, type=CapitalTypeEnum.STAMMKAPITAL # type: ignore
|
||||||
)
|
)
|
||||||
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)
|
result = transform.map_capital(data, CompanyTypeEnum.OHG) # type: ignore
|
||||||
assert result is None
|
assert result is None
|
||||||
|
|
||||||
|
|
||||||
@ -572,7 +572,7 @@ def test_map_unternehmensregister_json( # noqa: PLR0913
|
|||||||
mock_map_company_id: Mock,
|
mock_map_company_id: Mock,
|
||||||
) -> None:
|
) -> None:
|
||||||
expected_result = Company(
|
expected_result = Company(
|
||||||
**{
|
**{ # type: ignore
|
||||||
"id": Mock(),
|
"id": Mock(),
|
||||||
"name": Mock(),
|
"name": Mock(),
|
||||||
"location": Mock(),
|
"location": Mock(),
|
||||||
|
@ -103,7 +103,7 @@ def test_insert(mock_mongo_connector: Mock, mock_collection: Mock) -> None:
|
|||||||
mock_collection.insert_one.return_value = mock_result
|
mock_collection.insert_one.return_value = mock_result
|
||||||
assert (
|
assert (
|
||||||
service.insert(
|
service.insert(
|
||||||
Company(CompanyID("", ""), Location("Hier und Dort"), "", "", [])
|
Company(CompanyID("", ""), Location("Hier und Dort"), "", "", []) # type: ignore
|
||||||
)
|
)
|
||||||
== mock_result
|
== mock_result
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user