mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-06-22 00:23:55 +02:00
Rework the transfer of company data to fit the new data in the mongodb (#188)
This adds the additional company data as proposed to the sql db. - [x] @TrisNol Is everything included or did I miss a feature. Relations are in another issue. - [x] @KM-R New DB features for the Dashbord for your review.
This commit is contained in:
@ -14,7 +14,11 @@ from pytest_mock import MockerFixture
|
||||
from sqlalchemy.engine import Engine
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from aki_prj23_transparenzregister.models.company import CapitalTypeEnum, CurrencyEnum
|
||||
from aki_prj23_transparenzregister.models.company import (
|
||||
CapitalTypeEnum,
|
||||
CompanyTypeEnum,
|
||||
CurrencyEnum,
|
||||
)
|
||||
from aki_prj23_transparenzregister.utils import data_transfer
|
||||
from aki_prj23_transparenzregister.utils.sql import entities
|
||||
|
||||
@ -266,7 +270,23 @@ def company_generator(seed: int) -> dict[str, Any]:
|
||||
"zip_code": get_random_zip() if random.choice([True, False]) else None,
|
||||
"street": get_random_string(20) if random.choice([True, False]) else None,
|
||||
},
|
||||
"capital": random.choice(
|
||||
[
|
||||
{},
|
||||
None,
|
||||
{
|
||||
"value": random.randint(1000, 10000000),
|
||||
"currency": random.choice(["DM", "EUR"]),
|
||||
"type": random.choice(list(CapitalTypeEnum)),
|
||||
},
|
||||
]
|
||||
),
|
||||
"last_update": date(random.randint(2000, 2023), 1, 1).isoformat(),
|
||||
"company_type": random.choice(list(CompanyTypeEnum) + [None]), # type: ignore
|
||||
"founding_date": date(
|
||||
random.randint(2000, 2023), random.randint(1, 12), random.randint(1, 28)
|
||||
).isoformat(),
|
||||
"business_purpose": random.choice(["", "Some text", None]),
|
||||
}
|
||||
|
||||
|
||||
@ -675,18 +695,25 @@ def test_relationships(documents: list[dict[str, Any]], full_db: Session) -> Non
|
||||
1: "Other Company GmbH",
|
||||
2: "Third Company GmbH",
|
||||
},
|
||||
"company_type": {0: None, 1: None, 2: None},
|
||||
"founding_date": {0: pd.Timestamp(date.fromisoformat("2010-08-07"))},
|
||||
"business_purpose": {0: 'Say "Hello World"', 1: "Some purpose"},
|
||||
"street": {0: "Sesamstr.", 1: "Sesamstr.", 2: None},
|
||||
"zip_code": {0: "58644", 1: "58636", 2: None},
|
||||
"city": {0: "TV City", 1: "TV City", 2: None},
|
||||
"longitude": {0: 7.6968, 1: 7.7032, 2: None},
|
||||
"latitude": {0: 51.3246, 1: 51.38, 2: None},
|
||||
"pos_accuracy": {0: 4.0, 1: 4.0, 2: None},
|
||||
"house_number": {0: "4", 1: "8"},
|
||||
"zip_code": {0: "58644", 1: "58636"},
|
||||
"city": {0: "TV City", 1: "TV City"},
|
||||
"longitude": {0: 7.6968, 1: 7.7032},
|
||||
"latitude": {0: 51.3246, 1: 51.38},
|
||||
"pos_accuracy": {0: 4.0, 1: 4.0},
|
||||
"capital_value": {0: 1000000.0, 2: 10000.0},
|
||||
"original_currency": {0: "DEUTSCHE_MARK", 2: "EURO"},
|
||||
"capital_type": {0: "HAFTEINLAGE", 2: "GRUNDKAPITAL"},
|
||||
"last_update": {
|
||||
0: pd.Timestamp("2023-01-01 00:00:00"),
|
||||
1: pd.Timestamp("2023-01-01 00:00:00"),
|
||||
2: pd.Timestamp("2023-01-01 00:00:00"),
|
||||
},
|
||||
"sector": {0: None, 1: None, 2: None},
|
||||
"sector": {2: "Electronic"},
|
||||
}
|
||||
),
|
||||
)
|
||||
@ -1031,7 +1058,7 @@ def test_norm_capital_eur(currency: str, capital_type: str) -> None:
|
||||
{"value": 5, "currency": currency, "type": capital_type}
|
||||
) == {
|
||||
"capital_value": 5.0,
|
||||
"capital_currency": CurrencyEnum("EUR"),
|
||||
"original_currency": CurrencyEnum("EUR"),
|
||||
"capital_type": CapitalTypeEnum(capital_type),
|
||||
}
|
||||
|
||||
@ -1044,7 +1071,7 @@ def test_norm_capital_dm(currency: str, capital_type: CapitalTypeEnum) -> None:
|
||||
capital={"value": 5, "currency": currency, "type": capital_type}
|
||||
) == {
|
||||
"capital_value": 2.56,
|
||||
"capital_currency": CurrencyEnum("DM"),
|
||||
"original_currency": CurrencyEnum("DM"),
|
||||
"capital_type": CapitalTypeEnum(capital_type),
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user