Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
41 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"""Test the implementation of the data repository cache.""" | ||
|
||
from tests.cases.model import Entity | ||
|
||
from repository_orm.adapters.data.cache import Cache | ||
|
||
|
||
def test_cache_is_immutable_on_external_changes() -> None: | ||
""" | ||
Given: An entry in the cache | ||
When: an external function changes the entity | ||
Then: the cached version is unchanged | ||
""" | ||
entity = Entity(name="Original name") | ||
cache = Cache() | ||
cache.add(entity) | ||
entity.name = "Modified name" | ||
|
||
result = cache.get(entity) | ||
|
||
assert result.name == "Original name" | ||
assert not cache.entity_has_not_changed(entity) |