X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=csit%2Flibraries%2FIoTDM%2Friotdm.py;h=89dc39c12ac8b6facf9b8d1a89bac3b28b3b39cf;hb=1c106006ffb33c1c60e2f8abe61e88a7bd95a7bd;hp=8c2d6b00baded4f36e6c32d0faaf012592400061;hpb=e235045c2ad12d41416e2583609a0178c8bd9287;p=integration%2Ftest.git diff --git a/csit/libraries/IoTDM/riotdm.py b/csit/libraries/IoTDM/riotdm.py index 8c2d6b00ba..89dc39c12a 100644 --- a/csit/libraries/IoTDM/riotdm.py +++ b/csit/libraries/IoTDM/riotdm.py @@ -16,61 +16,68 @@ def create_resource(connection, parent, restype, a=None): else: x = connection.create(parent, restype, attr=a) if x is None: - raise AssertionError('Cannot create this resource') - elif hasattr(x, 'status_code'): + raise AssertionError("Cannot create this resource") + elif hasattr(x, "status_code"): if x.status_code < 200 or x.status_code > 299: raise AssertionError( - 'Cannot create this resource [%d] : %s' % - (x.status_code, x.text)) + "Cannot create this resource [%d] : %s" % (x.status_code, x.text) + ) return x + # this might not be necessary now that the library functions can take dicts def create_subscription(connection, parent, ip, port): uri = "http://%s:%d" % (ip, int(port)) - x = connection.create(parent, "subscription", { - "notificationURI": uri, - "notificationContentType": "wholeResource"}) + x = connection.create( + parent, + "subscription", + {"notificationURI": uri, "notificationContentType": "wholeResource"}, + ) if x is None: - raise AssertionError('Cannot create this subscription') - elif hasattr(x, 'status_code'): + raise AssertionError("Cannot create this subscription") + elif hasattr(x, "status_code"): if x.status_code < 200 or x.status_code > 299: - raise AssertionError('Cannot create subscription [%d] : %s' % - (x.status_code, x.text)) + raise AssertionError( + "Cannot create subscription [%d] : %s" % (x.status_code, x.text) + ) return x def retrieve_resource(connection, resid): x = connection.retrieve(resid) if x is None: - raise AssertionError('Cannot retrieve this resource') - elif hasattr(x, 'status_code'): + raise AssertionError("Cannot retrieve this resource") + elif hasattr(x, "status_code"): if x.status_code < 200 or x.status_code > 299: - raise AssertionError('Cannot retrieve this resource [%d] : %s' % - (x.status_code, x.text)) + raise AssertionError( + "Cannot retrieve this resource [%d] : %s" % (x.status_code, x.text) + ) return x def update_resource(connection, resid, attr): x = connection.update(resid, attr) if x is None: - raise AssertionError('Cannot update this resource') - elif hasattr(x, 'status_code'): + raise AssertionError("Cannot update this resource") + elif hasattr(x, "status_code"): if x.status_code < 200 or x.status_code > 299: - raise AssertionError('Cannot update this resource [%d] : %s' % - (x.status_code, x.text)) + raise AssertionError( + "Cannot update this resource [%d] : %s" % (x.status_code, x.text) + ) return x def delete_resource(connection, resid): x = connection.delete(resid) if x is None: - raise AssertionError('Cannot delete this resource') - elif hasattr(x, 'status_code'): + raise AssertionError("Cannot delete this resource") + elif hasattr(x, "status_code"): if x.status_code < 200 or x.status_code > 299: - raise AssertionError('Cannot delete this resource [%d] : %s' % - (x.status_code, x.text)) + raise AssertionError( + "Cannot delete this resource [%d] : %s" % (x.status_code, x.text) + ) return x