stackchain-dashboard/tests/test_following_store.py
timmy 5c43a5678a
Some checks failed
CI / lint (pull_request) Successful in 4m15s
CI / build-release (pull_request) Successful in 9s
CI / browser-journey (pull_request) Failing after 6m46s
CI / release-candidate (pull_request) Has been skipped
feat: add mobile Following queue for watched issues (Closes #1293)
2026-08-23 04:27:23 +00:00

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