31 lines
954 B
Python
31 lines
954 B
Python
import sqlite3
|
|
|
|
from src.following_store import FollowingStore
|
|
|
|
|
|
KEY = b"f" * 32
|
|
ITEM = {
|
|
"repository": "stackchain/api",
|
|
"number": 42,
|
|
"title": "Make mobile review useful",
|
|
"state": "open",
|
|
"updated_at": "2026-08-23T03:00:00Z",
|
|
"url": "https://forge.example/stackchain/api/issues/42",
|
|
}
|
|
|
|
|
|
def test_confirmed_watch_is_account_scoped_idempotent_and_encrypted(tmp_path):
|
|
path = tmp_path / "following.sqlite3"
|
|
store = FollowingStore(path, encryption_key=KEY, limit=50)
|
|
|
|
first = store.set_watching("Timmy", ITEM, True)
|
|
repeated = store.set_watching("timmy", ITEM, True)
|
|
|
|
assert first == repeated == {"revision": 1, "items": [ITEM]}
|
|
assert store.get("other") == {"revision": 0, "items": []}
|
|
stored = sqlite3.connect(path).execute(
|
|
"SELECT items FROM following_issues WHERE login = ?", ("timmy",)
|
|
).fetchone()[0]
|
|
assert ITEM["title"] not in stored
|
|
assert ITEM["repository"] not in stored
|