from __future__ import annotations from app.change_detection.structured_diff import diff_item_sets def test_diff_item_sets_detects_additions_and_removals(): previous = ["https://x.com/a", "https://x.com/b"] current = ["https://x.com/b", "https://x.com/c"] diff = diff_item_sets(previous, current) assert diff.added == ["https://x.com/c"] assert diff.removed == ["https://x.com/a"] assert diff.has_changes is True def test_diff_item_sets_no_change_when_identical(): items = ["https://x.com/a", "https://x.com/b"] diff = diff_item_sets(items, list(items)) assert diff.added == [] assert diff.removed == [] assert diff.has_changes is False def test_diff_item_sets_handles_empty_previous(): diff = diff_item_sets([], ["https://x.com/a"]) assert diff.added == ["https://x.com/a"] assert diff.removed == []