def testCreate(self):
     w = Widget()
     self.ps.create(w)
     w1 = self.ps.load(Widget, w._get_primaryKey())
     assert w1.been_wedgied() == w.been_wedgied() and w1._get_primaryKey() == w._get_primaryKey()
     Server.txn.commit(0)
     Server.txn.begin()
 def testUpdate(self):
     w = Widget()
     self.ps.create(w)
     Server.txn.commit(0)
     Server.txn.begin()
     w1 = self.ps.load(Widget, w._get_primaryKey())
     assert not w1.been_wedgied()
     w1._set_wedgie(1)
     self.ps.update(w1)
     Server.txn.commit(0)
     Server.txn.begin()
     w2 = self.ps.load(Widget, w._get_primaryKey())
     assert w2.been_wedgied()
    def testRollback(self):
        w = Widget()
        # Put in unwedgied
        self.ps.create(w)
        Server.txn.commit(0)
        Server.txn.begin()

        w1 = self.ps.load(Widget, w._get_primaryKey())
        w1.wedgie()
        assert w1.been_wedgied() != w.been_wedgied()

        # w1 should still be wedgied in this transaction
        w1 = self.ps.load(Widget, w._get_primaryKey())
        assert w1.been_wedgied() != w.been_wedgied()

        Server.txn.rollback()
        Server.txn.begin()
        w1 = self.ps.load(Widget, w._get_primaryKey())
        # Changes have been discarded so these two objects should match
        assert w1.been_wedgied() == w.been_wedgied()
 def testRemove(self):
     w = Widget()
     self.ps.create(w)
     w1 = self.ps.load(Widget, w._get_primaryKey())
     self.ps.remove(w1)
     self.assertRaises(KeyError, self.ps.load, Widget, w._get_primaryKey())