class DeviceDataManager: #Default Constructor def __init__(self): self.sensorAdaptor = MultiSensorAdaptor() self.ccc = CoapClientConnector() # Method execution block def run(self): i = 0 logging.info("Connecting to Server") while (i < 1): logging.info("Publishing data") message = DataUtil.toJsonFromSensorData( self.sensorAdaptor.getSensorData()) self.ccc.send(message) i += 1 sleep(5) logging.info("Finished Publishing") return True
class Module07Test(unittest.TestCase): """ Use this to setup your tests. This is where you may want to load configuration information (if needed), initialize class-scoped variables, create class-scoped instances of complex objects, initialize any requisite connections, etc. """ def setUp(self): self.ccc = CoapClientConnector() pass """ Use this to tear down any allocated resources after your tests are complete. This is where you may want to release connections, zero out any long-term data, etc. """ def tearDown(self): pass """ Place your comments describing the test here. """ def testSend(self): message = "Test" self.assertTrue(self.ccc.send(message), "Message issues") def testPut(self): message = "Test" self.assertTrue(self.ccc.put(message), "put issues") def testGet(self): message = "Test" self.assertTrue(self.ccc.get(), "get issues") def testPost(self): message = "Test" self.assertTrue(self.ccc.put(message), "put issues") def testDelete(self): message = "Test" self.assertTrue(self.ccc.delete(), "delete issues")