mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-06-21 23:43:55 +02:00
Repaired the SQL copy and reduced the log volume a bit (#141)
- Added a cli interface to the SQL copy - Repaired the SQL copy function - Added the SQL copy function to the scripts - Reduced the logging verbosity
This commit is contained in:
@ -571,23 +571,25 @@ def test_add_relationship_company_unknown(
|
||||
city: str | None,
|
||||
zip_code: str | None,
|
||||
full_db: Session,
|
||||
mocker: MockerFixture,
|
||||
) -> None:
|
||||
"""Tests if a relationship to another company can be added."""
|
||||
with pytest.raises(
|
||||
KeyError, match=f"No corresponding company could be found to {company_name}."
|
||||
):
|
||||
data_transfer.add_relationship(
|
||||
{
|
||||
"description": company_name,
|
||||
"location": {
|
||||
"zip_code": zip_code,
|
||||
"city": city,
|
||||
},
|
||||
"role": "organisation",
|
||||
spy_warning = mocker.spy(data_transfer.logger, "warning")
|
||||
spy_info = mocker.spy(data_transfer.logger, "info")
|
||||
data_transfer.add_relationship(
|
||||
{
|
||||
"description": company_name,
|
||||
"location": {
|
||||
"zip_code": zip_code,
|
||||
"city": city,
|
||||
},
|
||||
company_id,
|
||||
full_db,
|
||||
)
|
||||
"role": "organisation",
|
||||
},
|
||||
company_id,
|
||||
full_db,
|
||||
)
|
||||
spy_warning.assert_called_once()
|
||||
spy_info.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("empty_relations", [[], [{}], [{"relationship": []}]])
|
||||
@ -778,7 +780,7 @@ def test_add_annual_financial_reports_no_call(
|
||||
) -> None:
|
||||
"""Testing if financial reports are added correctly to the db."""
|
||||
spy_warning = mocker.spy(data_transfer.logger, "warning")
|
||||
info_warning = mocker.spy(data_transfer.logger, "info")
|
||||
spy_info = mocker.spy(data_transfer.logger, "info")
|
||||
mocker.patch("aki_prj23_transparenzregister.utils.data_transfer.add_annual_report")
|
||||
data_transfer.add_annual_financial_reports(companies, full_db)
|
||||
|
||||
@ -786,7 +788,7 @@ def test_add_annual_financial_reports_no_call(
|
||||
input_kwargs = mocker.call.kwargs
|
||||
assert len(input_args) == len(input_kwargs)
|
||||
spy_warning.assert_not_called()
|
||||
info_warning.assert_called_once()
|
||||
spy_info.assert_called_once()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@ -821,7 +823,7 @@ def test_add_annual_financial_reports_defect_year(
|
||||
) -> None:
|
||||
"""Testing if financial reports are added correctly to the db."""
|
||||
spy_warning = mocker.spy(data_transfer.logger, "warning")
|
||||
info_warning = mocker.spy(data_transfer.logger, "info")
|
||||
spy_info = mocker.spy(data_transfer.logger, "info")
|
||||
mocker.patch("aki_prj23_transparenzregister.utils.data_transfer.add_annual_report")
|
||||
data_transfer.add_annual_financial_reports(companies, full_db)
|
||||
|
||||
@ -829,7 +831,7 @@ def test_add_annual_financial_reports_defect_year(
|
||||
input_kwargs = mocker.call.kwargs
|
||||
assert len(input_args) == len(input_kwargs)
|
||||
spy_warning.assert_called_once()
|
||||
info_warning.assert_called_once()
|
||||
spy_info.assert_called_once()
|
||||
|
||||
|
||||
def test_add_annual_financial_reports(full_db: Session, mocker: MockerFixture) -> None:
|
||||
@ -864,7 +866,7 @@ def test_add_annual_financial_reports(full_db: Session, mocker: MockerFixture) -
|
||||
]
|
||||
|
||||
spy_warning = mocker.spy(data_transfer.logger, "warning")
|
||||
info_warning = mocker.spy(data_transfer.logger, "info")
|
||||
spy_info = mocker.spy(data_transfer.logger, "info")
|
||||
mocked = mocker.patch(
|
||||
"aki_prj23_transparenzregister.utils.data_transfer.add_annual_report"
|
||||
)
|
||||
@ -890,7 +892,7 @@ def test_add_annual_financial_reports(full_db: Session, mocker: MockerFixture) -
|
||||
for input_args in mocked.call_args_list:
|
||||
assert isinstance(input_args.kwargs["db"], Session)
|
||||
|
||||
info_warning.assert_called_once()
|
||||
spy_info.assert_called_once()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("year", list(range(2000, 2025, 5)))
|
||||
|
Reference in New Issue
Block a user