Задача 039: статус устройства и сведения об устройстве в списке адресов

Статус устройства (Активен / Выключен / На обслуживании), назначается вручную на экране
устройств: колонка «Статус», выбор в диалоге, смена — в журнал. Миграция 0016,
существующие устройства — «Активен». В списке адресов префикса колонки «Тип устройства»,
«Устройство», «Статус устройства» (join без N+1). pytest не прогнан: учётная запись admin
из .env отключена на стенде.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ayurishchevandClaude Opus 5.5 committed 2026-09-27 18:18:33 +03:00
1 parent aeb89dbded
commit 7d998066f5
10 files changed
+199 -19

No files matched your search

+15
View File
@@ -64,6 +64,21 @@ def test_in_use_objects_cannot_be_deleted(client, org):
client.delete(f"/users/{uid}")
def test_device_status_on_address(client, org):
"""Изменение 039: статус устройства отдаётся в списке адресов префикса и меняется через PATCH /devices/{id}."""
p = _prefix(client, org, "10.205.0.0/24").json()
t = client.get("/device-types").json()["items"][0]
dev = client.post("/devices", json={"name": "svc-1.internal", "device_type_id": t["id"], "organization_id": org["id"], "status": "maintenance"}).json()
assert dev["status"] == "maintenance"
client.post(f"/prefixes/{p['id']}/addresses", json={"address": "10.205.0.1", "device_id": dev["id"]})
page = client.get(f"/prefixes/{p['id']}/addresses").json()
a = next(x for x in page["items"] if x["address"] == "10.205.0.1")
assert a["device_name"] == "svc-1.internal" and a["device_type_name"] == t["name"] and a["device_status"] == "maintenance"
upd = client.patch(f"/devices/{dev['id']}", json={"status": "off"})
assert upd.status_code == 200 and upd.json()["status"] == "off"
def test_delete_organization(client, org):
_prefix(client, org, "10.206.0.0/24")
busy = client.delete(f"/organizations/{org['id']}") # с префиксом — нельзя