mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 13:52:15 +01:00
fix: review fixes for the restore fix
- A restore of the repeaters alone saves them before the reboot, instead of leaving that to somfy.loop(). - e2e: a refused restore leaves no upload behind, tested on its own. - e2e: auth() sits next to upload(), whose file part is now file=. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3d45ba59c1
commit
d968f7e70c
3 changed files with 25 additions and 13 deletions
|
|
@ -8,17 +8,13 @@ import pytest
|
|||
|
||||
from proto_client import run_sync
|
||||
from test_commands import is_ok, op, synced_model
|
||||
from test_routes import http, upload
|
||||
from test_routes import auth, http, restore_without_a_file, upload
|
||||
from test_settings import desc, settings, uptime, wait_for_restart
|
||||
|
||||
# Saved for the round trip and put back by the restore. .invalid never resolves.
|
||||
CHANGED_NTP_SERVER = "restore.e2e.invalid"
|
||||
|
||||
|
||||
def auth(token):
|
||||
return {"apikey": token} if token else {}
|
||||
|
||||
|
||||
def test_restore_reads_the_options_sent_as_a_form_field(host, token):
|
||||
"""The options come as the form field "data", next to the file.
|
||||
|
||||
|
|
@ -32,6 +28,15 @@ def test_restore_reads_the_options_sent_as_a_form_field(host, token):
|
|||
assert json.loads(body)["desc"] == "JSON parse error"
|
||||
|
||||
|
||||
def test_a_refused_restore_leaves_no_upload_behind(host, token):
|
||||
"""A later /restore without a file must not find the refused one's upload."""
|
||||
status, _, _ = upload(host, "/restore", auth(token), fields={"data": "{"})
|
||||
assert status == 500
|
||||
status, reason = restore_without_a_file(host, token)
|
||||
assert status == 400
|
||||
assert "didn't complete" in reason, reason
|
||||
|
||||
|
||||
def test_a_restore_brings_back_the_parts_that_were_ticked(request, host, token, connect, schema):
|
||||
if not request.config.getoption("--reboot"):
|
||||
pytest.skip("restores a backup and reboots the device: pass --reboot")
|
||||
|
|
@ -48,7 +53,7 @@ def test_a_restore_brings_back_the_parts_that_were_ticked(request, host, token,
|
|||
assert is_ok(schema, reply), desc(schema, reply)
|
||||
try:
|
||||
options = json.dumps({"shades": False, "settings": True})
|
||||
status, _, body = upload(host, "/restore", auth(token), content=backup, fields={"data": options})
|
||||
status, _, body = upload(host, "/restore", auth(token), file=backup, fields={"data": options})
|
||||
assert status == 200, body
|
||||
wait_for_restart(host, token, schema, uptime_before)
|
||||
finally:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue