Skip to content

Commit 10ac381

Browse files
committed
add test
1 parent b2784bc commit 10ac381

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

chatmaild/src/chatmaild/tests/test_metadata.py

+16
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,22 @@ def test_requeue_removes_tmp_files(notifier, metadata, testaddr, caplog):
242242
assert queue_item.addr == testaddr
243243

244244

245+
def test_requeue_removes_invalid_files(notifier, metadata, testaddr, caplog):
246+
metadata.add_token_to_addr(testaddr, "01234")
247+
notifier.new_message_for_addr(testaddr, metadata)
248+
# empty/invalid files should be ignored
249+
p = notifier.queue_dir.joinpath("1203981203")
250+
p.touch()
251+
notifier2 = notifier.__class__(notifier.queue_dir)
252+
notifier2.requeue_persistent_queue_items()
253+
assert "spurious" in caplog.records[0].msg
254+
assert not p.exists()
255+
assert notifier2.retry_queues[0].qsize() == 1
256+
when, queue_item = notifier2.retry_queues[0].get()
257+
assert when <= int(time.time())
258+
assert queue_item.addr == testaddr
259+
260+
245261
def test_start_and_stop_notification_threads(notifier, testaddr):
246262
threads = notifier.start_notification_threads(None)
247263
for retry_num, threadlist in threads.items():

0 commit comments

Comments
 (0)