unifi_access/tests/test_device.py

43 lines
1.5 KiB
Python

import responses
from responses import matchers
from .base import UnifiAccessTests
class CredentialTests(UnifiAccessTests):
@responses.activate
def test_fetch_devices(self) -> None:
"""8.1 Fetch Devices"""
responses.get(
f"https://{self.host}/api/v1/developer/devices",
match=[matchers.header_matcher(self.common_headers)],
json={
"code": "SUCCESS",
# XXX: verify correct response, as per note
# NOTE: api docs had this as a list of lists of objects
"data": [
{
"full_name": "UNVR - Main Floor - Door 3855 - UA-HUB-3855",
"id": "7483c2773855",
"name": "UA-HUB-3855",
"type": "UAH",
},
{
"full_name": "UNVR - Main Floor - Door 3855 - out - UA-LITE-8CED",
"id": "f492bfd28ced",
"name": "UA-LITE-8CED",
"type": "UDA-LITE",
},
{
"full_name": "UNVR - Main Floor - Door 3855 - in - UA-G2-PRO-BB7A",
"id": "0418d6a2bb7a",
"name": "UA-G2-PRO-BB7A",
"type": "UA-G2-PRO",
},
],
"msg": "success",
},
)
resp = self.client.fetch_devices()
assert resp[0].name == "UA-HUB-3855"