mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-06-21 23:53:55 +02:00
Add an list of missing relation partners to be searched (#171)
- [x] Add a new table - [x] Add a field to the table that can register if the company was already queried - [x] Add a field to the table that counts how many times a relation partner was missing - [x] Add a function that restets the counter Also: - Reworked the get_company function to use the location dict as kwargs
This commit is contained in:
@ -1050,6 +1050,92 @@ def test_add_annual_report_financial_key_error(full_db: Session) -> None:
|
||||
)
|
||||
|
||||
|
||||
def test_company_relation_missing(empty_db: Session) -> None:
|
||||
"""Check if adding missing company to a query list works."""
|
||||
data_transfer.company_relation_missing("Some_company", None, None, empty_db)
|
||||
empty_db.commit()
|
||||
data_transfer.company_relation_missing("Other_company", None, "some city", empty_db)
|
||||
empty_db.commit()
|
||||
data_transfer.company_relation_missing(
|
||||
"Some_company",
|
||||
**{"city": "some city", "zip_code": "12345", "street": "some-street"},
|
||||
db=empty_db,
|
||||
)
|
||||
empty_db.commit()
|
||||
|
||||
pd.testing.assert_frame_equal(
|
||||
pd.read_sql_table(
|
||||
entities.MissingCompany.__tablename__, empty_db.bind # type: ignore
|
||||
).set_index("name"),
|
||||
pd.DataFrame(
|
||||
[
|
||||
{
|
||||
"name": "Some_company",
|
||||
"zip_code": "12345",
|
||||
"city": "some city",
|
||||
"number_of_links": 2,
|
||||
"searched_for": False,
|
||||
},
|
||||
{
|
||||
"name": "Other_company",
|
||||
"zip_code": None,
|
||||
"city": "some city",
|
||||
"number_of_links": 1,
|
||||
"searched_for": False,
|
||||
},
|
||||
]
|
||||
).set_index("name"),
|
||||
)
|
||||
|
||||
|
||||
def test_company_relation_missing_reset(empty_db: Session) -> None:
|
||||
"""Tests the reset of missing company relation counts."""
|
||||
empty_db.add_all(
|
||||
[
|
||||
entities.MissingCompany(
|
||||
name="Some Company",
|
||||
city="city",
|
||||
zip_code="12345",
|
||||
number_of_links=5,
|
||||
searched_for=True,
|
||||
),
|
||||
entities.MissingCompany(
|
||||
name="Other Company",
|
||||
city="city2",
|
||||
zip_code="98765",
|
||||
number_of_links=1,
|
||||
searched_for=False,
|
||||
),
|
||||
]
|
||||
)
|
||||
empty_db.commit()
|
||||
data_transfer.reset_relation_counter(empty_db)
|
||||
queried_df = pd.read_sql_table(
|
||||
entities.MissingCompany.__tablename__, empty_db.bind # type: ignore
|
||||
).set_index("name")
|
||||
pd.testing.assert_frame_equal(
|
||||
queried_df,
|
||||
pd.DataFrame(
|
||||
[
|
||||
{
|
||||
"name": "Some Company",
|
||||
"zip_code": "12345",
|
||||
"city": "city",
|
||||
"number_of_links": 0,
|
||||
"searched_for": True,
|
||||
},
|
||||
{
|
||||
"name": "Other Company",
|
||||
"zip_code": "98765",
|
||||
"city": "city2",
|
||||
"number_of_links": 0,
|
||||
"searched_for": False,
|
||||
},
|
||||
]
|
||||
).set_index("name"),
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("capital_type", [_.value for _ in CapitalTypeEnum])
|
||||
@pytest.mark.parametrize("currency", ["€", "EUR"])
|
||||
def test_norm_capital_eur(currency: str, capital_type: str) -> None:
|
||||
|
Reference in New Issue
Block a user