2023-11-04 14:19:41 +01:00

47 lines
1.7 KiB
Python

"""Test load utils from Unternehmensregister."""
import json
import tempfile
from unittest.mock import Mock, patch
from aki_prj23_transparenzregister.utils.data_extraction.unternehmensregister import (
load,
)
def test_smoke() -> None:
assert load
@patch(
"aki_prj23_transparenzregister.utils.data_extraction.unternehmensregister.load.CompanyMongoService"
)
def test_load_directory_to_mongo(mock_company_service: Mock) -> None:
mock_company_service.migration_of_base_data.return_value = None
with tempfile.TemporaryDirectory() as tmp_dir:
with open(f"{tmp_dir}/test.json", "w") as f:
mock_company = {
"id": {
"district_court": {
"name": "Amtsgericht Hamburg",
"city": "Hamburg",
},
"hr_number": "HRB 47899",
},
"location": {
"city": "Hamburg",
"street": "Heußweg",
"house_number": "35",
"zip_code": "20255",
},
"name": "Aurelius Immo GmbH",
"last_update": "2021-07-05",
"relationships": [],
"business_purpose": "Erwerb und Verwaltung von Immobilien; Geschäftsführung von Immobilienfonds und anderen Gesellschaften; Dienstleistungen in diesem Zusammenhang.",
"capital": {"value": 50000, "currency": "DM", "type": "Stammkapital"},
"company_type": "Gesellschaft mit beschränkter Haftung",
"founding_date": "1977-03-03",
}
json.dump(mock_company, f)
result = load.load_directory_to_mongo(tmp_dir, mock_company_service)
assert result == 1