def test_get_lock_detail_bridge_offline(self, mock): mock.register_uri( "get", API_GET_LOCK_URL.format(lock_id="ABC"), text=load_fixture("get_lock.offline.json"), ) api = Api() lock = api.get_lock_detail(ACCESS_TOKEN, "ABC") self.assertEqual("ABC", lock.device_id) self.assertEqual("Test", lock.device_name) self.assertEqual("houseid", lock.house_id) self.assertEqual("ABC", lock.serial_number) self.assertEqual("undefined-1.59.0-1.13.2", lock.firmware_version) self.assertEqual(-100, lock.battery_level) self.assertEqual("AUG-X", lock.model) self.assertEqual(False, lock.bridge_is_online) self.assertEqual(None, lock.keypad) self.assertEqual(None, lock.bridge) self.assertEqual(False, lock.doorsense) self.assertEqual(LockStatus.UNKNOWN, lock.lock_status) self.assertEqual(LockDoorStatus.UNKNOWN, lock.door_state) self.assertEqual(None, lock.lock_status_datetime) self.assertEqual(None, lock.door_state_datetime)
def test_get_lock_detail_with_doorsense_bridge_online(self, mock): mock.register_uri( "get", API_GET_LOCK_URL.format(lock_id="ABC"), text=load_fixture("get_lock.online_with_doorsense.json"), ) api = Api() lock = api.get_lock_detail(ACCESS_TOKEN, "ABC") self.assertEqual("ABC", lock.device_id) self.assertEqual("Online door with doorsense", lock.device_name) self.assertEqual("123", lock.house_id) self.assertEqual("XY", lock.serial_number) self.assertEqual("undefined-4.3.0-1.8.14", lock.firmware_version) self.assertEqual(92, lock.battery_level) self.assertEqual("AUG-MD01", lock.model) self.assertEqual(None, lock.keypad) self.assertIsInstance(lock.bridge, BridgeDetail) self.assertIsInstance(lock.bridge.status, BridgeStatusDetail) self.assertEqual(BridgeStatus.ONLINE, lock.bridge.status.current) self.assertEqual(True, lock.bridge_is_online) self.assertEqual(True, lock.bridge.operative) self.assertEqual(True, lock.doorsense) self.assertEqual(LockStatus.LOCKED, lock.lock_status) self.assertEqual(LockDoorStatus.OPEN, lock.door_state) self.assertEqual( dateutil.parser.parse("2017-12-10T04:48:30.272Z"), lock.lock_status_datetime ) self.assertEqual( dateutil.parser.parse("2017-12-10T04:48:30.272Z"), lock.door_state_datetime )
def test_get_lock_detail_bridge_online(self, mock): mock.register_uri( "get", API_GET_LOCK_URL.format(lock_id="A6697750D607098BAE8D6BAA11EF8063"), text=load_fixture("get_lock.online.json"), ) api = Api() lock = api.get_lock_detail(ACCESS_TOKEN, "A6697750D607098BAE8D6BAA11EF8063") self.assertEqual("A6697750D607098BAE8D6BAA11EF8063", lock.device_id) self.assertEqual("Front Door Lock", lock.device_name) self.assertEqual("000000000000", lock.house_id) self.assertEqual("X2FSW05DGA", lock.serial_number) self.assertEqual("109717e9-3.0.44-3.0.30", lock.firmware_version) self.assertEqual(88, lock.battery_level) self.assertEqual("AUG-SL02-M02-S02", lock.model) self.assertEqual("Medium", lock.keypad.battery_level) self.assertEqual(60, lock.keypad.battery_percentage) self.assertEqual("5bc65c24e6ef2a263e1450a8", lock.keypad.device_id) self.assertIsInstance(lock.bridge, BridgeDetail) self.assertEqual(True, lock.bridge_is_online) self.assertEqual(True, lock.bridge.operative) self.assertEqual(True, lock.doorsense) self.assertEqual(LockStatus.LOCKED, lock.lock_status) self.assertEqual(LockDoorStatus.CLOSED, lock.door_state) self.assertEqual( dateutil.parser.parse("2017-12-10T04:48:30.272Z"), lock.lock_status_datetime ) self.assertEqual( dateutil.parser.parse("2017-12-10T04:48:30.272Z"), lock.door_state_datetime )
async def test_async_get_lock_detail_doorsense_init_state(self, mock): mock.get( API_GET_LOCK_URL.format(lock_id="A6697750D607098BAE8D6BAA11EF8063"), body=load_fixture("get_lock.doorsense_init.json"), ) api = ApiAsync(ClientSession()) lock = await api.async_get_lock_detail( ACCESS_TOKEN, "A6697750D607098BAE8D6BAA11EF8063" ) self.assertEqual("A6697750D607098BAE8D6BAA11EF8063", lock.device_id) self.assertEqual("Front Door Lock", lock.device_name) self.assertEqual("000000000000", lock.house_id) self.assertEqual("X2FSW05DGA", lock.serial_number) self.assertEqual("109717e9-3.0.44-3.0.30", lock.firmware_version) self.assertEqual(88, lock.battery_level) self.assertEqual("Medium", lock.keypad.battery_level) self.assertEqual("5bc65c24e6ef2a263e1450a8", lock.keypad.device_id) self.assertEqual("AK-R1", lock.keypad.model) self.assertEqual("Front Door Lock Keypad", lock.keypad.device_name) self.assertIsInstance(lock.bridge, BridgeDetail) self.assertEqual(True, lock.bridge_is_online) self.assertEqual(True, lock.bridge.operative) self.assertEqual(False, lock.doorsense) self.assertEqual(LockStatus.LOCKED, lock.lock_status) self.assertEqual(LockDoorStatus.UNKNOWN, lock.door_state) self.assertEqual( dateutil.parser.parse("2017-12-10T04:48:30.272Z"), lock.lock_status_datetime ) self.assertEqual( dateutil.parser.parse("2017-12-10T04:48:30.272Z"), lock.door_state_datetime ) lock.lock_status = LockStatus.UNLOCKED self.assertEqual(LockStatus.UNLOCKED, lock.lock_status) lock.door_state = LockDoorStatus.OPEN self.assertEqual(LockDoorStatus.OPEN, lock.door_state) lock.lock_status_datetime = dateutil.parser.parse("2020-12-10T04:48:30.272Z") self.assertEqual( dateutil.parser.parse("2020-12-10T04:48:30.272Z"), lock.lock_status_datetime ) lock.door_state_datetime = dateutil.parser.parse("2019-12-10T04:48:30.272Z") self.assertEqual( dateutil.parser.parse("2019-12-10T04:48:30.272Z"), lock.door_state_datetime )