mirror of
https://github.com/Matysh/houseplan-card
synced 2026-07-31 08:28:31 +00:00
test: config cap under aiohttp's 4 MB frame; own marker id for the upload test
A 4 MB cap could never be reported: the frame limit rejects the message first and the socket closes with 1009, so the user gets a dropped connection instead of 'too_large'. 2 MB is ~30x a real three-floor configuration (70 KB measured). The upload test listed a folder test_ha_upload.py also writes into.
This commit is contained in:
@@ -81,10 +81,12 @@ MAX_KNOWN_DEVICES = 20000
|
|||||||
MAX_TEXT = 500 # names, models, ids
|
MAX_TEXT = 500 # names, models, ids
|
||||||
MAX_DESCRIPTION = 4000
|
MAX_DESCRIPTION = 4000
|
||||||
MAX_URL = 2000
|
MAX_URL = 2000
|
||||||
# Below the WebSocket frame limit on purpose: a payload larger than that never
|
# Comfortably below the WebSocket frame limit (aiohttp's default is 4 MB): a
|
||||||
# reaches the handler at all — the socket closes with 1009 and the user sees a
|
# payload larger than the frame never reaches the handler at all — the socket
|
||||||
# dropped connection instead of an error they can act on.
|
# closes with 1009 and the user sees a dropped connection instead of an error
|
||||||
MAX_CONFIG_BYTES = 4 * 1024 * 1024
|
# they can act on. For scale, a real three-floor home with ~200 devices stores
|
||||||
|
# about 70 KB, so this is ~30x headroom.
|
||||||
|
MAX_CONFIG_BYTES = 2 * 1024 * 1024
|
||||||
|
|
||||||
_TEXT = vol.All(str, vol.Length(max=MAX_TEXT))
|
_TEXT = vol.All(str, vol.Length(max=MAX_TEXT))
|
||||||
_TEXT_OR_NONE = vol.Any(None, _TEXT)
|
_TEXT_OR_NONE = vol.Any(None, _TEXT)
|
||||||
|
|||||||
@@ -681,12 +681,12 @@ async def test_upload_never_overwrites_an_existing_attachment(
|
|||||||
assert resp.status == 200, await resp.text()
|
assert resp.status == 200, await resp.text()
|
||||||
return (await resp.json())["url"]
|
return (await resp.json())["url"]
|
||||||
|
|
||||||
first = await upload("m1", "manual.pdf", b"ONE")
|
first = await upload("m9", "manual.pdf", b"ONE")
|
||||||
second = await upload("m1", "manual.pdf", b"TWO")
|
second = await upload("m9", "manual.pdf", b"TWO")
|
||||||
assert first != second, "the second upload must not take the first name"
|
assert first != second, "the second upload must not take the first name"
|
||||||
|
|
||||||
folder = os.path.join(hass.config.path(FILES_DIR), "m1")
|
folder = os.path.join(hass.config.path(FILES_DIR), "m9")
|
||||||
# the HA test config dir is shared across the module — look only at ours
|
# the HA test config dir is shared across the module — hence our own marker id
|
||||||
names = sorted(
|
names = sorted(
|
||||||
n for n in await hass.async_add_executor_job(os.listdir, folder) if n.startswith("manual")
|
n for n in await hass.async_add_executor_job(os.listdir, folder) if n.startswith("manual")
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user