Skip to content

Commit

Permalink
Add a test for unknown messages sent to the recoder
Browse files Browse the repository at this point in the history
  • Loading branch information
pkhalaj committed Jun 10, 2024
1 parent 7f50198 commit 583284d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions trolldb/tests/test_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ def del_message(tmp_data_filename):
'"polarization": "hh", "sensor": "sar-c", "format": "GeoTIFF", "pass_direction": "ASCENDING"}')


@pytest.fixture()
def unknown_message(tmp_data_filename):
"""Create a string for an unknown message."""
return ("pytroll://deletion some_unknown_key [email protected] 2019-11-05T13:00:10.366023 v1.01 "
"application/json {}")


@pytest.fixture()
def tmp_data_filename(tmp_path):
"""Create a filename for the messages."""
Expand Down Expand Up @@ -119,3 +126,13 @@ async def test_record_dataset_messages(tmp_path, dataset_message):
with patched_subscriber_recv([dataset_message]):
await record_messages(config)
assert await message_in_database_and_delete_count_is_one(msg)


async def test_unknown_messages(check_log, tmp_path, unknown_message):
"""Tests that we identify the message as being unknown, and we log that."""
config = AppConfig(**make_test_app_config_as_dict(tmp_path))
with running_prepared_database_context():
with patched_subscriber_recv([unknown_message]):
await record_messages(config)

assert check_log("DEBUG", "Don't know what to do with some_unknown_key message")

0 comments on commit 583284d

Please sign in to comment.