mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-06-21 23:33:54 +02:00
Added a filter for financial reports. (#372)
Finanical reports are now filtered before beeing added to the SQL database to only added knwon keys. Some matching is also done. The most importend missing reports are printed to be implemented later on. Rapidfuzz could be used.
This commit is contained in:
@ -1143,19 +1143,6 @@ def test_add_annual_report_unknown_audit(
|
||||
assert added.number_of_links == number_of_years
|
||||
|
||||
|
||||
def test_add_annual_report_financial_key_error(full_db: Session) -> None:
|
||||
"""Tests if an error is thrown financial data is tried to be added with an unknown financial record type."""
|
||||
with pytest.raises(
|
||||
TypeError, match="is an invalid keyword argument for AnnualFinanceStatement"
|
||||
):
|
||||
data_transfer.add_annual_report(
|
||||
2,
|
||||
2023,
|
||||
{"financials": {"something-strange": 123.12}, "auditors": {}},
|
||||
db=full_db,
|
||||
)
|
||||
|
||||
|
||||
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)
|
||||
@ -1311,3 +1298,18 @@ def test_transfer_data_cli_env(
|
||||
|
||||
data_transfer.transfer_data_cli()
|
||||
spy.assert_called_once()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("given", "expected"),
|
||||
[
|
||||
({}, {}),
|
||||
({"REVENUE": 2}, {"revenue": 2}),
|
||||
({"GROSS PROFIT": 10}, {"gross_profit": 10}),
|
||||
({"I dont know this one": 5, "GROSS PROFIT": 10}, {"gross_profit": 10}),
|
||||
({"I dont know this one": 5}, {}),
|
||||
],
|
||||
)
|
||||
def test_filter_financials(given: dict[str, float], expected: dict[str, int]) -> None:
|
||||
"""Tests if the financial data can be filtered correctly."""
|
||||
assert data_transfer.filter_financials(given) == expected
|
||||
|
Reference in New Issue
Block a user