Пример #1
0
 def test_b(self):
     filename = tempfile.mktemp()
     s = FileStorage2(filename)
     connection = Connection(s)
     root = connection.get_root()
     root['a'] = Persistent()
     root['a'].b = 1
     connection.commit()
     root['b'] = Persistent()
     connection.commit()
     root['b'].a = root['a']
     root['a'].b = 2
     connection.commit()
     root['a'].b = 3
     connection.commit()
     s.close()
     hc = HistoryConnection(filename)
     a = hc.get_root()['a']
     assert len(hc.get_storage().index.history) == 6
     hc.previous_instance(a)
     assert a.b == 2
     hc.previous_instance(a)
     assert a.b == 1
     hc.previous_instance(a)
     assert not hasattr(a, '__dict__')
     assert hc.get_root().keys() == []
     hc.get_storage().fp.close()
     os.unlink(filename)