auto-discovery toggle, auto-prune with customizable retention
This commit is contained in:
parent
7ebf35b137
commit
f8f9cb6337
4 changed files with 115 additions and 4 deletions
|
|
@ -429,6 +429,28 @@ def test_announce_handler():
|
|||
shutil.rmtree(dir_a)
|
||||
|
||||
|
||||
def test_prune_old_content():
|
||||
"""Old threads should be pruned after retention period."""
|
||||
dir_a = tempfile.mkdtemp()
|
||||
try:
|
||||
fdb = ForumDB(dir_a)
|
||||
now = "2026-06-05T12:00:00"
|
||||
old = "2026-01-01T12:00:00"
|
||||
fdb.create_thread("new_t", "New", "", "", "", "aaa", "", now)
|
||||
fdb.create_thread("old_t", "Old", "", "", "", "bbb", "", old)
|
||||
fdb.create_post("old_p", "old_t", "", "old reply", "bbb", "", old)
|
||||
|
||||
# Prune with 30 day retention — old thread is ~5 months old
|
||||
fdb.prune_old_content(30)
|
||||
|
||||
assert fdb.get_thread("new_t") is not None, "new thread should survive"
|
||||
assert fdb.get_thread("old_t") is None, "old thread should be pruned"
|
||||
assert len(list(fdb.get_posts("old_t"))) == 0, "old posts should be pruned"
|
||||
finally:
|
||||
import shutil
|
||||
shutil.rmtree(dir_a)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_sync_thread()
|
||||
test_sync_reply()
|
||||
|
|
@ -440,4 +462,5 @@ if __name__ == "__main__":
|
|||
test_sync_updated_content()
|
||||
test_sync_peer_discovery()
|
||||
test_announce_handler()
|
||||
test_prune_old_content()
|
||||
print("all sync tests passed")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue