Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Catch errors in write_addition if unique_key isn't implemented
Adding a test that ensures that an exception is raised if the object passed to write_addition function doesn't have a unique_key.
- Loading branch information
Showing
3 changed files
with
27 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Kumar Shivendu |
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,14 @@ | ||
import pytest | ||
|
||
from swh.journal.writer import model_object_dict_sanitizer | ||
from swh.journal.writer.inmemory import InMemoryJournalWriter | ||
from swh.model.model import BaseModel | ||
|
||
|
||
def test_write_addition_errors_without_unique_key(): | ||
writer = InMemoryJournalWriter[BaseModel]( | ||
value_sanitizer=model_object_dict_sanitizer | ||
) | ||
|
||
with pytest.raises(NotImplementedError): | ||
writer.write_addition("BaseModel", BaseModel()) |
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