mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 13:52:15 +01:00
fix: edit ops review findings
From the review of 7723711:
- The assembler is locked: a client closed for a full queue is closed
by the task that was sending, loop(), whose disconnect dropped the
buffer while async_tcp could be copying into it. A whole message is
taken out of it, so a disconnect can't free it while it is read.
- loop() expires a message stalled for 10 s, freeing its buffer and
telling its client, instead of holding it until another client came.
A binary message is refused before it can touch another's buffer.
- Each edit takes only the fields its route reads; one it would ignore
is refused by name. linkRemote's rolling code goes in under the
route's name, so applyModelEdit is unchanged again.
- An edit refused for an id that doesn't exist replies not found
(edit_result_t::missing). A reply that doesn't fit its buffer goes
as an internal error, so the op still gets one.
- The TYPE table says what becomes of each op (proto_op_t), which the
socket switches on. The reply address is one proto_reply_to_t. The
routes and the ops start and queue an edit the same way
(newModelEdit, submitModelEdit). The full-list texts and the offered
remote address rule live in ModelEditor.
- e2e: the sort order test skips a list that it would renumber.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
77237111ea
commit
8fa087aa89
23 changed files with 486 additions and 257 deletions
|
|
@ -75,15 +75,27 @@ def test_an_edit_of_a_missing_shade_says_why(connect, schema):
|
|||
"""Refused by the edit itself on loop(), as its route would be."""
|
||||
c, shades, _ = synced_model(connect, schema)
|
||||
reply = op(c, schema, "saveShade", {"shadeId": unused(shades, "shadeId"), "name": "x"})
|
||||
assert error_name(schema, reply) == "badRequest"
|
||||
assert error_name(schema, reply) == "notFound"
|
||||
assert reply["d"][schema.keys["desc"]] == "Shade Id not found."
|
||||
|
||||
|
||||
def test_a_field_an_edit_doesnt_take_is_refused(connect, schema):
|
||||
c, shades, _ = synced_model(connect, schema)
|
||||
reply = op(c, schema, "saveShade", {"shadeId": unused(shades, "shadeId"), "paired": 1})
|
||||
assert error_name(schema, reply) == "badRequest"
|
||||
assert reply["d"][schema.keys["desc"]] == "paired can't be set by this edit"
|
||||
|
||||
|
||||
def test_a_sort_order_set_to_what_it_is(connect, schema):
|
||||
c, shades, _ = synced_model(connect, schema)
|
||||
if not shades:
|
||||
pytest.skip("the device has no shades")
|
||||
ids = [s["shadeId"] for s in sorted(shades, key=lambda s: s.get("sortOrder", 0))]
|
||||
ordered = sorted(shades, key=lambda s: s.get("sortOrder", 0))
|
||||
# A sort order numbers the shades 0, 1, 2...: only a list already numbered
|
||||
# so stays as it is.
|
||||
if [s.get("sortOrder", 0) for s in ordered] != list(range(len(ordered))):
|
||||
pytest.skip("the shades' sort orders have gaps or repeats, which a sort order would renumber")
|
||||
ids = [s["shadeId"] for s in ordered]
|
||||
reply = op(c, schema, "shadeSortOrder", {"ids": ids})
|
||||
assert is_ok(schema, reply)
|
||||
order = c.recv_until(lambda f: f["t"] == schema.type_numbers["shadeOrder"])[-1]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue