diff --git a/CONTRIBUTORS b/CONTRIBUTORS new file mode 100644 --- /dev/null +++ b/CONTRIBUTORS @@ -0,0 +1 @@ +Kumar Shivendu diff --git a/swh/journal/tests/test_inmemory.py b/swh/journal/tests/test_inmemory.py new file mode 100644 --- /dev/null +++ b/swh/journal/tests/test_inmemory.py @@ -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()) diff --git a/swh/journal/tests/test_kafka_writer.py b/swh/journal/tests/test_kafka_writer.py --- a/swh/journal/tests/test_kafka_writer.py +++ b/swh/journal/tests/test_kafka_writer.py @@ -228,3 +228,15 @@ with pytest.raises(KafkaDeliveryError): writer.write_addition("directory", empty_dir) + + +def test_write_addition_errors_without_unique_key(kafka_prefix: str, kafka_server: str): + writer = KafkaJournalWriter[BaseModel]( + brokers=[kafka_server], + client_id="kafka_writer", + prefix=kafka_prefix, + value_sanitizer=model_object_dict_sanitizer, + ) + + with pytest.raises(NotImplementedError): + writer.write_addition("BaseModel", BaseModel())