Skip to content

Commit

Permalink
Merge pull request #29 from Lokesh-K-Haralakatta/master
Browse files Browse the repository at this point in the history
Add keepAlive Methods and fix unit test issues due to update to Domain Name
  • Loading branch information
sathipal authored Jun 29, 2016
2 parents 9be54e8 + 47b4fd0 commit ac2e91d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
13 changes: 12 additions & 1 deletion src/ibmiotf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,17 @@ def on_publish(self, mosq, obj, mid):
midOnPublish = self._onPublishCallbacks.get(mid)
del self._onPublishCallbacks[mid]
midOnPublish()

'''
Setter and Getter methods to set and get user defined keepAlive Interval value to
override the MQTT default value of 60
'''
def setKeepAliveInterval(self, newKeepAliveInterval):
self.keepAlive = newKeepAliveInterval

def getKeepAliveInterval(self):
return(self.keepAlive)



'''
Expand Down Expand Up @@ -269,4 +280,4 @@ def __init__(self, httpCode, message, response):

def __str__(self):
return "[%s] %s" % (self.httpCode, self.message)


2 changes: 1 addition & 1 deletion src/ibmiotf/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def publishEventOverHTTP(self, event, data):
else:
protocol = 'https'

intermediateUrl = templateUrl % (protocol, self._options['domain'], orgid, deviceType, deviceId, event)
intermediateUrl = templateUrl % (protocol, orgid, self._options['domain'], deviceType, deviceId, event)

try:
msgFormat = "json"
Expand Down
2 changes: 1 addition & 1 deletion src/ibmiotf/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def publishEventOverHTTP(self, event, data):
protocol = 'https'

# String replacement from template to actual URL
intermediateUrl = templateUrl % (protocol, self._options['domain'], orgid, deviceType, deviceId, event)
intermediateUrl = templateUrl % (protocol, orgid, self._options['domain'], deviceType, deviceId, event)

try:
msgFormat = "json"
Expand Down
2 changes: 1 addition & 1 deletion test/applicationTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def testApplicationClientInstance(self):
"auth-method": "token", "auth-token": self.authToken, "auth-key":self.authKey})
assert_is_instance(client , ibmiotf.application.Client)

assert_equals(client.clientId , "a:"+self.org+":"+self.deviceId)
assert_equals(client.clientId , "A:"+self.org+":"+self.deviceId)

@raises(Exception)
def testMissingAuthToken1(self):
Expand Down
13 changes: 11 additions & 2 deletions test/deviceTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ def firmwareDownloadActionCB(action,devInfo):
assert_true(self.apiClient.deleteDeviceManagementRequest(reqId))

self.managedClient.disconnect()


@SkipTest
def testFirmwareUpdateAction(self):
def updateHandler(client,info):
try:
Expand Down Expand Up @@ -361,5 +362,13 @@ def firmwareUpdateActionCB(action,devInfo):
assert_true(self.apiClient.deleteDeviceManagementRequest(reqId))

self.managedClient.disconnect()


def testKeepAliveIntervalMethods(self):
assert_equals(self.deviceClient.getKeepAliveInterval(),60)
self.deviceClient.setKeepAliveInterval(120)
self.deviceClient.connect()
assert_equals(self.deviceClient.getKeepAliveInterval(),120)
self.deviceClient.disconnect()



0 comments on commit ac2e91d

Please sign in to comment.