def test_application_functions(self): self.q = Queue.Queue() def cb(key, value): self.q.put({"key": key, "value": value}) application = appmanager.Application( calvinuuid.uuid('APP'), "test_app", [calvinuuid.uuid('ACTOR'), calvinuuid.uuid('ACTOR')], calvinuuid.uuid("NODE"), None) self.storage.add_application(application, cb=CalvinCB(cb)) yield wait_for(self.q.empty, condition=lambda x: not x()) value = self.q.get(timeout=.001) # print value self.storage.get_application(application.id, cb=CalvinCB(func=cb)) yield wait_for(self.q.empty, condition=lambda x: not x()) value = self.q.get(timeout=.001) # print value assert value["key"] == application.id and value["value"][ "name"] == application.name self.storage.delete_application(application.id, cb=CalvinCB(func=cb)) yield wait_for(self.q.empty, condition=lambda x: not x()) value = self.q.get(timeout=.001) assert application.id not in self.storage.localstore
def test_application_functions(self): self.q = Queue.Queue() def cb(key, value): self.q.put({"key": key, "value": value}) yield threads.defer_to_thread(time.sleep, 2) application = appmanager.Application(calvinuuid.uuid( 'APP'), "test_app", [calvinuuid.uuid('ACTOR'), calvinuuid.uuid('ACTOR')]) yield threads.defer_to_thread(self.storage.add_application, application, cb=CalvinCB(cb)) yield threads.defer_to_thread(time.sleep, 2) value = self.q.get(timeout=0.2) assert value["value"] is True yield threads.defer_to_thread(self.storage.get_application, application.id, cb=CalvinCB(cb)) yield threads.defer_to_thread(time.sleep, 2) value = self.q.get(timeout=0.2) assert value["value"]["name"] == application.name yield threads.defer_to_thread(self.storage.delete_application, application.id, cb=CalvinCB(cb)) yield threads.defer_to_thread(time.sleep, 2) value = self.q.get(timeout=0.2) assert value["value"] is True yield threads.defer_to_thread(self.storage.get_application, application.id, cb=CalvinCB(cb)) yield threads.defer_to_thread(time.sleep, 2) value = self.q.get(timeout=0.2) assert value["value"] is None
def test_application_functions(self): self.q = Queue.Queue() def cb(key, value): self.q.put({"key": key, "value": value}) application = appmanager.Application( calvinuuid.uuid('APP'), "test_app", [calvinuuid.uuid('ACTOR'), calvinuuid.uuid('ACTOR')], calvinuuid.uuid("NODE"), None) self.storage.add_application(application, cb=CalvinCB(cb)) yield wait_for(self.q.empty, condition=lambda x: not x()) value = self.q.get(timeout=.001) assert isinstance(value["value"], calvinresponse.CalvinResponse ) and value["value"] == calvinresponse.OK self.storage.get_application(application.id, cb=CalvinCB(cb)) yield wait_for(self.q.empty, condition=lambda x: not x()) value = self.q.get(timeout=.001) assert value["value"]["name"] == application.name self.storage.delete_application(application.id, cb=CalvinCB(cb)) yield wait_for(self.q.empty, condition=lambda x: not x()) value = self.q.get(timeout=.001) assert isinstance(value["value"], calvinresponse.CalvinResponse ) and value["value"] == calvinresponse.OK self.storage.get_application(application.id, cb=CalvinCB(cb)) yield wait_for(self.q.empty, condition=lambda x: not x()) value = self.q.get(timeout=.001) assert isinstance(value["value"], calvinresponse.CalvinResponse ) and value["value"] == calvinresponse.NOT_FOUND
def test_application_functions(self): self.q = Queue.Queue() def cb(key, value): self.q.put({"key": key, "value": value}) application = appmanager.Application(calvinuuid.uuid( 'APP'), "test_app", [calvinuuid.uuid('ACTOR'), calvinuuid.uuid('ACTOR')]) self.storage.add_application(application) value = self.storage.get_application( application.id, cb=CalvinCB(func=cb)) value = self.q.get(timeout=0.2) assert value["key"] == application.id and value[ "value"]["name"] == application.name self.storage.delete_application(application.id, cb=CalvinCB(func=cb)) value = self.q.get(timeout=0.2) assert value assert application.id not in self.storage.localstore