def test_queryCheckpoint(self): """ Test that a newly created Item is checkpointed before a query is executed. """ store = Store() def txn(): item = TestItem(store=store) list(store.query(TestItem)) self.assertEquals(self.checkpointed, [item]) store.transact(txn)
def test_transactionTouchCheckpoint(self): """ Test that in a transaction an existing Item is checkpointed if it has touch called on it and the store it is in is checkpointed. """ store = Store() item = TestItem(store=store) # Get rid of the entry that's there from creation self.checkpointed = [] def txn(): item.touch() store.checkpoint() self.assertEquals(self.checkpointed, [item]) store.transact(txn)
def test_twoQueriesOneCheckpoint(self): """ Test that if two queries are performed in a transaction, a touched item only has checkpoint called on it before the first. """ store = Store() item = TestItem(store=store) # Get rid of the entry that's there from creation self.checkpointed = [] def txn(): item.touch() list(store.query(TestItem)) self.assertEquals(self.checkpointed, [item]) list(store.query(TestItem)) self.assertEquals(self.checkpointed, [item]) store.transact(txn)
def test_transactionCheckpoint(self): """ Test that an Item is checkpointed when the transaction it is created within is committed. """ store = Store() def txn(): item = TestItem(store=store) self.assertEquals(self.checkpointed, []) return item item = store.transact(txn) self.assertEquals(self.checkpointed, [item])