def testUnmanage(self, gateway): try: option = { "identity": { "orgId": "test", "typeId": "xxx", "deviceId": "xxx" }, "auth": { "token": gateway.authToken }, } testVariable = 3600 test = ManagedGatewayClient(option) test2 = test.unmanage() assert True except: assert False == True
def testManagedDeviceMgmtResponseError(self, gateway): with pytest.raises(Exception) as e: config = { "identity": { "orgId": "1", "typeId": "xxx", "deviceId": "xxx" }, "auth": { "token": gateway.authToken }, } managedDevice = ManagedGatewayClient(config) testValue = "Test" encodedPayload = Utf8Codec.encode(testValue) managedDevice._ManagedGatewayClient__onDeviceMgmtResponse( client=1, userdata=2, pahoMessage=encodedPayload) assert "Unable to parse JSON. payload=" " error" in str(e.value)
def testOnDeviceCommand0Lifetime(self, gateway): try: option = { "identity": { "orgId": "test", "typeId": "xxx", "deviceId": "xxx" }, "auth": { "token": gateway.authToken }, } testVariable = 3599 test = ManagedGatewayClient(option) test2 = test.manage(lifetime=testVariable) assert True except: assert False == True
def testSetPropertyNameError(self, gateway): with pytest.raises(Exception) as e: option = { "identity": { "orgId": "test", "typeId": "xxx", "deviceId": "xxx" }, "auth": { "token": gateway.authToken }, } test = ManagedGatewayClient(option).setProperty(name="test", value="test2") assert "Unsupported property name: " in str(e.value)
def testSetErrorCodesValue(self, gateway): try: option = { "identity": { "orgId": "test", "typeId": "xxx", "deviceId": "xxx" }, "auth": { "token": gateway.authToken }, } testVariable = 3600 test = ManagedGatewayClient(option).clearErrorCodes() assert True except: assert False == True
def testSetPropertyName(self, gateway): try: option = { "identity": { "orgId": "test", "typeId": "xxx", "deviceId": "xxx" }, "auth": { "token": gateway.authToken }, } test = ManagedGatewayClient(option).setProperty(name="model", value="test2") assert True except: assert False == True
def testSubscribeToNotifications(self, gateway): try: option = { "identity": { "orgId": "test", "typeId": "xxx", "deviceId": "xxx" }, "auth": { "token": gateway.authToken }, } test = ManagedGatewayClient(option).subscribeToNotifications() test assert True except: assert False == True
def testPublishEvent(self, gateway): try: option = { "identity": { "orgId": "test", "typeId": "xxx", "deviceId": "xxx" }, "auth": { "token": gateway.authToken }, } test = ManagedGatewayClient(option).publishEvent(eventId="test", msgFormat="test2", data="test3") test assert True except: assert False == True