mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 19:57:07 +00:00
Format zwave_js dump as json (#46792)
This commit is contained in:
parent
4d23ffacd1
commit
47dcd2bf32
@ -281,9 +281,9 @@ class DumpView(HomeAssistantView):
|
||||
msgs = await dump.dump_msgs(entry.data[CONF_URL], async_get_clientsession(hass))
|
||||
|
||||
return web.Response(
|
||||
body="\n".join(json.dumps(msg) for msg in msgs) + "\n",
|
||||
body=json.dumps(msgs, indent=2) + "\n",
|
||||
headers={
|
||||
hdrs.CONTENT_TYPE: "application/jsonl",
|
||||
hdrs.CONTENT_DISPOSITION: 'attachment; filename="zwave_js_dump.jsonl"',
|
||||
hdrs.CONTENT_TYPE: "application/json",
|
||||
hdrs.CONTENT_DISPOSITION: 'attachment; filename="zwave_js_dump.json"',
|
||||
},
|
||||
)
|
||||
|
@ -1,4 +1,5 @@
|
||||
"""Test the Z-Wave JS Websocket API."""
|
||||
import json
|
||||
from unittest.mock import patch
|
||||
|
||||
from zwave_js_server.event import Event
|
||||
@ -164,7 +165,7 @@ async def test_dump_view(integration, hass_client):
|
||||
):
|
||||
resp = await client.get(f"/api/zwave_js/dump/{integration.entry_id}")
|
||||
assert resp.status == 200
|
||||
assert await resp.text() == '{"hello": "world"}\n{"second": "msg"}\n'
|
||||
assert json.loads(await resp.text()) == [{"hello": "world"}, {"second": "msg"}]
|
||||
|
||||
|
||||
async def test_dump_view_invalid_entry_id(integration, hass_client):
|
||||
|
Loading…
x
Reference in New Issue
Block a user