Exemple #1
0
class StateSaveBufferTestCase(TestCase):
    @setup
    def setup_buffer(self):
        self.buffer_size = 5
        self.buffer = StateSaveBuffer(self.buffer_size)

    def test_save(self):
        assert self.buffer.save(1, 2)
        assert not self.buffer.save(1, 3)
        assert not self.buffer.save(1, 4)
        assert not self.buffer.save(1, 5)
        assert not self.buffer.save(1, 6)
        assert self.buffer.save(1, 7)
        assert_equal(self.buffer.buffer[1], 7)

    def test__iter__(self):
        self.buffer.save(1, 2)
        self.buffer.save(2, 3)
        items = list(self.buffer)
        assert not self.buffer.buffer
        assert_equal(items, [(1, 2), (2, 3)])
Exemple #2
0
class TestStateSaveBuffer(TestCase):
    @setup
    def setup_buffer(self):
        self.buffer_size = 5
        self.buffer = StateSaveBuffer(self.buffer_size)

    def test_save(self):
        assert self.buffer.save(1, 2)
        assert not self.buffer.save(1, 3)
        assert not self.buffer.save(1, 4)
        assert not self.buffer.save(1, 5)
        assert not self.buffer.save(1, 6)
        assert self.buffer.save(1, 7)
        assert_equal(self.buffer.buffer[1], 7)

    def test__iter__(self):
        self.buffer.save(1, 2)
        self.buffer.save(2, 3)
        items = list(self.buffer)
        assert not self.buffer.buffer
        assert_equal(items, [(1, 2), (2, 3)])
Exemple #3
0
 def setup_manager(self):
     self.store = mock.Mock()
     self.store.build_key.side_effect = lambda t, i: '%s%s' % (t, i)
     self.buffer = StateSaveBuffer(1)
     self.manager = PersistentStateManager(self.store, self.buffer)
Exemple #4
0
 def setup_buffer(self):
     self.buffer_size = 5
     self.buffer = StateSaveBuffer(self.buffer_size)
Exemple #5
0
 def setup_buffer(self):
     self.buffer_size = 5
     self.buffer = StateSaveBuffer(self.buffer_size)