Example #1
0
 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
Example #2
0
 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)
Example #3
0
 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
Example #4
0
 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)
Example #5
0
 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
Example #6
0
 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
Example #7
0
 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
Example #8
0
 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