def test_unlock(self, mock): lock_id = 1234 mock.register_uri("put", API_UNLOCK_URL.format(lock_id=lock_id), text="{\"status\": \"unlocked\"}") api = Api() status = api.unlock(ACCESS_TOKEN, lock_id) self.assertEqual(LockStatus.UNLOCKED, status)
def test_unlock_from_fixture(self, mock): lock_id = 1234 mock.register_uri( "put", API_UNLOCK_URL.format(lock_id=lock_id), text=load_fixture("unlock.json"), ) api = Api() status = api.unlock(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)