Esempio n. 1
0
    def test_get_lock_status_with_unknown_status_response(self, mock):
        lock_id = 1234
        mock.register_uri("get",
                          API_GET_LOCK_STATUS_URL.format(lock_id=lock_id),
                          text="{\"status\": \"not_advertising\"}")

        api = Api()
        status = api.get_lock_status(ACCESS_TOKEN, lock_id)

        self.assertEqual(LockStatus.UNKNOWN, status)
Esempio n. 2
0
    def test_get_lock_status_with_unlocked_response(self, mock):
        lock_id = 1234
        mock.register_uri("get",
                          API_GET_LOCK_STATUS_URL.format(lock_id=lock_id),
                          text="{\"status\": \"kAugLockState_Unlocked\"}")

        api = Api()
        status = api.get_lock_status(ACCESS_TOKEN, lock_id)

        self.assertEqual(LockStatus.UNLOCKED, status)
class SmartLock:
    def __init__(self):
        self.api = Api(timeout=20)
        self.authenticator = Authenticator(
            self.api,
            "phone|email",
            "YourPhoneNumber",
            "YourPassword",
            access_token_cache_file="access_token_cache_file.txt")
        self.id = 'EBE57CE9D7624D78A5A0BE44340E0DFE'
        self.authentication = self.authenticator.authenticate()
        self.access_token = self.authentication.access_token

    def get_smartlock_status(self):
        self.api.get_lock_status(self.access_token, self.id)

    def unlock(self):
        unlock_response = self.api.unlock(self.access_token, self.id)
        print(unlock_response)
Esempio n. 4
0
    def test_get_lock_and_door_status_with_locked_response(self, mock):
        lock_id = 1234
        mock.register_uri("get",
                          API_GET_LOCK_STATUS_URL.format(lock_id=lock_id),
                          text="{\"status\": \"kAugLockState_Locked\""
                          ",\"doorState\": \"kAugLockDoorState_Closed\"}")

        api = Api()
        status, door_status = api.get_lock_status(ACCESS_TOKEN, lock_id, True)

        self.assertEqual(LockStatus.LOCKED, status)
        self.assertEqual(LockDoorStatus.CLOSED, door_status)