Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
TT-69 fix: add tests
  • Loading branch information
Guido Quezada committed Dec 18, 2020
commit d5482a619786f2bd04cfefc42e67e45fc9545208
35 changes: 35 additions & 0 deletions tests/time_tracker_api/time_entries/time_entries_model_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from unittest.mock import Mock, patch
import pytest
from faker import Faker

Expand Down Expand Up @@ -231,3 +232,37 @@ def test_find_running_should_not_find_any_item(
time_entry_repository.find_running(tenant_id, owner_id)
except Exception as e:
assert type(e) is StopIteration


@patch(
'commons.data_access_layer.cosmos_db.CosmosDBRepository.on_update',
new_callable=Mock,
)
def test_updated_item_with_deleted_key_should_not_call_validate_data(
on_update_mock,
event_context: EventContext,
time_entry_repository: TimeEntryCosmosDBRepository,
):

time_entry_repository.validate_data = Mock()
time_entry_repository.replace_empty_value_per_none = Mock()
time_entry_repository.on_update({'deleted': '01234'}, event_context)
on_update_mock.assert_called_once()
time_entry_repository.validate_data.assert_not_called()


@patch(
'commons.data_access_layer.cosmos_db.CosmosDBRepository.on_update',
new_callable=Mock,
)
def test_updated_item_without_deleted_key_should_call_validate_data(
on_update_mock,
event_context: EventContext,
time_entry_repository: TimeEntryCosmosDBRepository,
):

time_entry_repository.validate_data = Mock()
time_entry_repository.replace_empty_value_per_none = Mock()
time_entry_repository.on_update({}, event_context)
on_update_mock.assert_called_once()
time_entry_repository.validate_data.assert_called_once()