chore: snapshots.py polish — hoisted imports + strict kind + mtime doc (T105)
This commit is contained in:
@@ -156,6 +156,28 @@ def test_restore_snapshot_wrong_confirm_400(client, tmp_path):
|
||||
assert response.status_code == 400
|
||||
|
||||
|
||||
def test_restore_without_kind_returns_400(client, tmp_path):
|
||||
"""T105: Missing or empty ``kind`` must be rejected with 400.
|
||||
|
||||
Previously ``kind`` defaulted to ``"periodic"``, which silently 404'd
|
||||
when the caller meant a rewind snapshot. Tighten the contract so the
|
||||
client must always pass an explicit, valid ``kind``.
|
||||
"""
|
||||
db_path = tmp_path / "test.db"
|
||||
_seed_bot(db_path, "bot_a", "BotA")
|
||||
snapshot_path = _take_snapshot_via_service(
|
||||
db_path, tmp_path, kind="periodic"
|
||||
)
|
||||
snapshot_id = snapshot_path.stem
|
||||
|
||||
response = client.post(
|
||||
f"/snapshots/restore/{snapshot_id}",
|
||||
data={"confirm_id": snapshot_id}, # no `kind`
|
||||
follow_redirects=False,
|
||||
)
|
||||
assert response.status_code == 400
|
||||
|
||||
|
||||
def test_preview_renders_metadata(client, tmp_path):
|
||||
db_path = tmp_path / "test.db"
|
||||
_seed_bot(db_path, "bot_a", "BotA")
|
||||
|
||||
Reference in New Issue
Block a user