def testSimpleRecordCreation(self): currentTS = 0 a1 = ActionWrapper(currentTS, self._objs[1], ['add'], None) a2 = ActionWrapper(currentTS, self._objs[2], ['add'], None) self._mgr.add(currentTS, [a1, a2]) currentTS += 1 # check current available/borrowed books self._agt1.run(currentTS, logger=self._logger) self._agt1.acknowledge() # nice! all of them are available! service should confirm that... self.assertEqual( self._srvc1.getAll(), set([('Der Process', 'available'), ('Angels and Demons', 'available')])) self.assertEqual(self._srvc2.getAll(), set([])) currentTS += 1 self._agt2.run(currentTS, logger=self._logger) self._agt2.acknowledge() self.assertEqual( self._srvc2.getAll(), set([('Der Process', 'available'), ('Angels and Demons', 'available')]))
def testDeletionNotification(self): currentTS = 0 a1 = ActionWrapper(currentTS, self._objs[1], ['add'], None) a2 = ActionWrapper(currentTS, self._objs[2], ['add'], None) a3 = ActionWrapper(currentTS + 1, self._objs[2], ['del'], None) self._mgr.add(currentTS, [a1, a2]) currentTS += 1 # check currently available/borrowed books self._agt1.run(currentTS, logger=self._logger) self._agt1.acknowledge() self._mgr.add(currentTS, [a3]) currentTS += 1 # check current available/borrowed books self._agt2.run(currentTS, logger=self._logger) self._agt2.acknowledge() self.assertEqual( self._srvc1.getAll(), set([('Der Process', 'available'), ('Angels and Demons', 'available')])) self.assertEqual(self._srvc2.getAll(), set([('Angels and Demons', 'available')]))
def testEventWorkflow(self): evt1 = DummyWrapper('evt1') evt2 = DummyWrapper('evt2') self.assertEqual( set(list(BistateRecordProcessor.computeRecords([ (1, ActionWrapper(1, evt1, ['data_changed', 'created'])), (2, ActionWrapper(1, evt2, ['data_changed', 'created'])), (3, ActionWrapper(2, evt1, ['deleted'])), (4, ActionWrapper(2, evt2, ['data_changed']))], None))), set([(evt1, STATUS_CREATED | STATUS_CHANGED | STATUS_DELETED), (evt2, STATUS_CREATED | STATUS_CHANGED)]))
def testChangeNotification(self): currentTS = 0 a1 = ActionWrapper(currentTS, self._objs[0], ['add'], None) a2 = ActionWrapper(currentTS + 1, self._objs[0], ['chg'], None) a3 = ActionWrapper(currentTS + 2, self._objs[0], ['chg'], None) self._mgr.add(currentTS, [a1]) currentTS += 1 # check current available/borrowed books self._agt1.run(currentTS, logger=self._logger) self._agt1.acknowledge() # srvc2 should be out of sync self.assertEqual(self._srvc1.getAll(), set([('Python Cookbook', 'available')])) self.assertEqual(self._srvc2.getAll(), set([])) # change to borrowed self._mgr.add(currentTS, [a2]) currentTS += 1 self._agt2.run(currentTS, logger=self._logger) self._agt2.acknowledge() # srvc1 should be out of sync self.assertEqual(self._srvc1.getAll(), set([('Python Cookbook', 'available')])) self.assertEqual(self._srvc2.getAll(), set([('Python Cookbook', 'borrowed')])) # change back to available self._mgr.add(currentTS, [a3]) currentTS += 1 self._agt1.run(currentTS, logger=self._logger) self._agt1.acknowledge() # srvc2 should be out of sync self.assertEqual(self._srvc1.getAll(), set([('Python Cookbook', 'available')])) self.assertEqual(self._srvc2.getAll(), set([('Python Cookbook', 'borrowed')])) currentTS += 1