mirror of
https://github.com/Matysh/houseplan-card
synced 2026-07-31 08:28:31 +00:00
test: the plans folder is shared across the module
Assert on our own two files rather than the whole listing.
This commit is contained in:
@@ -1132,8 +1132,9 @@ async def test_stored_plans_can_be_listed_and_deleted_on_request(
|
|||||||
rev = (await _save(client, await _cfg([{"id": "p1", "plan_url": used_url}]), 0))["result"]["rev"]
|
rev = (await _save(client, await _cfg([{"id": "p1", "plan_url": used_url}]), 0))["result"]["rev"]
|
||||||
|
|
||||||
await client.send_json_auto_id({"type": "houseplan/plans/list"})
|
await client.send_json_auto_id({"type": "houseplan/plans/list"})
|
||||||
|
# the HA test config dir is shared across the module: look at ours, not all
|
||||||
plans = {p["name"]: p for p in (await client.receive_json())["result"]["plans"]}
|
plans = {p["name"]: p for p in (await client.receive_json())["result"]["plans"]}
|
||||||
assert set(plans) == {used, free}
|
assert {used, free} <= set(plans)
|
||||||
assert plans[used]["used_by"] and not plans[free]["used_by"]
|
assert plans[used]["used_by"] and not plans[free]["used_by"]
|
||||||
assert plans[used]["size"] == 4 and plans[free]["url"].endswith(free)
|
assert plans[used]["size"] == 4 and plans[free]["url"].endswith(free)
|
||||||
|
|
||||||
@@ -1150,8 +1151,9 @@ async def test_stored_plans_can_be_listed_and_deleted_on_request(
|
|||||||
await _save(client, await _cfg([{"id": "p1", "plan_url": None}]), rev)
|
await _save(client, await _cfg([{"id": "p1", "plan_url": None}]), rev)
|
||||||
await client.send_json_auto_id({"type": "houseplan/plans/list"})
|
await client.send_json_auto_id({"type": "houseplan/plans/list"})
|
||||||
plans = {p["name"]: p for p in (await client.receive_json())["result"]["plans"]}
|
plans = {p["name"]: p for p in (await client.receive_json())["result"]["plans"]}
|
||||||
assert list(plans) == [used], "the detached plan is still there, ready to re-attach"
|
assert used in plans, "the detached plan is still there, ready to re-attach"
|
||||||
assert not plans[used]["used_by"]
|
assert not plans[used]["used_by"]
|
||||||
|
assert free not in plans, "and the one we deleted is gone"
|
||||||
|
|
||||||
# nothing outside the plans folder can be reached through the name
|
# nothing outside the plans folder can be reached through the name
|
||||||
await client.send_json_auto_id(
|
await client.send_json_auto_id(
|
||||||
|
|||||||
Reference in New Issue
Block a user