|
| 1 | +from unittest.mock import Mock, patch |
1 | 2 | import pytest
|
2 | 3 | from faker import Faker
|
3 | 4 |
|
@@ -231,3 +232,37 @@ def test_find_running_should_not_find_any_item(
|
231 | 232 | time_entry_repository.find_running(tenant_id, owner_id)
|
232 | 233 | except Exception as e:
|
233 | 234 | 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