def test_listeners(self): # Use a list to beat the closure called = [False] def loc_listener(obj, var, value): called.remove(False) called.append(True) self.assertEquals("_id", var) self.assertEquals(1, value) loc = Location() loc.set_listener(loc_listener) loc.id = 1 self.assertTrue(called[0])
def test_listeners(self): # Use a list to beat the closure called = [False] def loc_listener(obj, var, value): called.remove(False) called.append(True) self.assertEquals("_id", var) self.assertEquals(1, value) loc = Location() loc.set_listener(loc_listener) loc.id = 1 self.assertTrue(called[0])
def test_listeners(self): # Use a list to beat the closure called = [False] def loc_listener(obj, var, value): # The listener will be called when the object is posted # and when it is committed, so we want to filter out the # post call if var == "_id" and value > 0: called.remove(False) called.append(True) loc = Location() loc.name = "Test Loc1" loc.set_listener(loc_listener) work = self.ingester_platform.createUnitOfWork() work.post(loc) work.commit() self.assertTrue(called[0])
def test_listeners(self): # Use a list to beat the closure called = [False] def loc_listener(obj, var, value): # The listener will be called when the object is posted # and when it is committed, so we want to filter out the # post call if var == "_id" and value > 0: called.remove(False) called.append(True) loc = Location() loc.name = "Test Loc1" loc.set_listener(loc_listener) work = self.ingester_platform.createUnitOfWork() work.post(loc) work.commit() self.assertTrue(called[0])