Skip to content

Commit fe83686

Browse files
author
Guido Quezada
committed
TT-69 fix: add tests
1 parent 4e9438d commit fe83686

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/time_tracker_api/time_entries/time_entries_model_test.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from unittest.mock import Mock, patch
12
import pytest
23
from faker import Faker
34

@@ -231,3 +232,37 @@ def test_find_running_should_not_find_any_item(
231232
time_entry_repository.find_running(tenant_id, owner_id)
232233
except Exception as e:
233234
assert type(e) is StopIteration
235+
236+
237+
@patch(
238+
'commons.data_access_layer.cosmos_db.CosmosDBRepository.on_update',
239+
new_callable=Mock,
240+
)
241+
def test_updated_item_with_deleted_key_should_not_call_validate_data(
242+
on_update_mock,
243+
event_context: EventContext,
244+
time_entry_repository: TimeEntryCosmosDBRepository,
245+
):
246+
247+
time_entry_repository.validate_data = Mock()
248+
time_entry_repository.replace_empty_value_per_none = Mock()
249+
time_entry_repository.on_update({'deleted': '01234'}, event_context)
250+
on_update_mock.assert_called_once()
251+
time_entry_repository.validate_data.assert_not_called()
252+
253+
254+
@patch(
255+
'commons.data_access_layer.cosmos_db.CosmosDBRepository.on_update',
256+
new_callable=Mock,
257+
)
258+
def test_updated_item_without_deleted_key_should_call_validate_data(
259+
on_update_mock,
260+
event_context: EventContext,
261+
time_entry_repository: TimeEntryCosmosDBRepository,
262+
):
263+
264+
time_entry_repository.validate_data = Mock()
265+
time_entry_repository.replace_empty_value_per_none = Mock()
266+
time_entry_repository.on_update({}, event_context)
267+
on_update_mock.assert_called_once()
268+
time_entry_repository.validate_data.assert_called_once()

0 commit comments

Comments
 (0)