Esempio n. 1
0
 def test_newer_miss(self):
     from appendonly import _Layer
     klass = self._getTargetClass()
     source = _Layer()
     source.push(object())
     copied = klass.fromLayer(source)
     self.assertEqual(list(copied.newer(0)), [])
Esempio n. 2
0
 def test___iter___filled(self):
     from appendonly import _Layer
     klass = self._getTargetClass()
     source = _Layer()
     OBJ1 = object()
     OBJ2 = object()
     OBJ3 = object()
     source.push(OBJ1)
     source.push(OBJ2)
     source.push(OBJ3)
     copied = klass.fromLayer(source)
     self.assertEqual(list(copied), [(2, OBJ3), (1, OBJ2), (0, OBJ1)])
Esempio n. 3
0
 def test_newer_hit(self):
     from appendonly import _Layer
     klass = self._getTargetClass()
     source = _Layer()
     OBJ1 = object()
     OBJ2 = object()
     OBJ3 = object()
     source.push(OBJ1)
     source.push(OBJ2)
     source.push(OBJ3)
     copied = klass.fromLayer(source)
     self.assertEqual(list(copied.newer(0)),
                      [(2, OBJ3), (1, OBJ2)])
Esempio n. 4
0
 def test_fromLayer(self):
     from appendonly import _Layer
     klass = self._getTargetClass()
     source = _Layer(max_length=42, generation=13)
     for i in range(25):
         obj = object()
         source.push(obj)
     copied = klass.fromLayer(source)
     self.assertEqual(copied._max_length, 42)
     self.assertEqual(copied._generation, 13)
     self.assertEqual(len(copied._stack), len(source._stack))
     for s_obj, c_obj in zip(source._stack, copied._stack):
         self.assertTrue(s_obj is c_obj)