fix: Add script to fix malformed yearly_result entries

This commit is contained in:
TrisNol
2023-10-07 09:11:43 +02:00
parent 5137026fab
commit 9cc58ba8be
3 changed files with 53 additions and 7 deletions

View File

@ -160,3 +160,35 @@ def test_add_yearly_reslults(mock_mongo_connector: Mock, mock_collection: Mock)
mock_result: list = [{"_id": "abc", "brille?": "Fielmann", "Hotel?": "Trivago"}]
mock_collection.update_one.return_value = mock_result
assert service.add_yearly_results("612316a1e198338c3b44299e", {}) == mock_result
def test_get_where_malformed_yearly_results(
mock_mongo_connector: Mock, mock_collection: Mock
) -> None:
mock_mongo_connector.database = {"companies": mock_collection}
service = CompanyMongoService(mock_mongo_connector)
mock_result: list = [
{
"_id": "abc",
"name": "Fielmann",
"Hotel?": "Trivago",
"yearly_results": {"Vor Aeonen": 42, "2022": 4711},
},
{
"_id": "abc",
"name": "Fielmann",
"Hotel?": "Trivago",
"yearly_results": {"1998": 42, "2022": 4711},
},
{
"_id": "abc",
"name": "Fielmann",
"Hotel?": "Trivago",
"yearly_results": {"19": 42, "2022": 4711},
},
]
mock_collection.find.return_value = mock_result
assert service.get_where_malformed_yearly_results() == [
mock_result[0],
mock_result[2],
]