def setUp(self):
     self._checkpoint = CompositeCheckpoint()
     cp1 = DataCheckpoint()
     cp1.append('abc')
     cp2 = DataCheckpoint()
     cp2.append('def')
     self._checkpoint.add_checkpoint(cp1)
     self._checkpoint.add_checkpoint(cp2)
 def test_set_item(self):
     cp1 = DataCheckpoint()
     cp1.append('abc')
     cp2 = DataCheckpoint()
     cp2.append('def')
     self._checkpoint.add_checkpoint(cp1)
     self.assertEqual(self._checkpoint[0].data, 'abc')
     self._checkpoint[0] = cp2
     self.assertEqual(self._checkpoint[0].data, 'def')
class TestDataCheckpoint(unittest.TestCase):
    def setUp(self):
        self._checkpoint = DataCheckpoint()

    def test_operator_bool_false_on_init(self):
        self.assertFalse(self._checkpoint)

    def test_operator_bool_true_with_data(self):
        self._checkpoint.replace('abc')
        self.assertTrue(self._checkpoint)

    def test_replace(self):
        self._checkpoint.replace('abc')
        self.assertEqual(self._checkpoint.data, 'abc')
        self._checkpoint.replace('def')
        self.assertEqual(self._checkpoint.data, 'def')

    def test_append(self):
        self._checkpoint.append('abc')
        self.assertEqual(self._checkpoint.data, 'abc')
        self._checkpoint.append('def')
        self.assertEqual(self._checkpoint.data, 'abcdef')

    def test_clear(self):
        self._checkpoint.append('abc')
        self.assertEqual(self._checkpoint.data, 'abc')
        self._checkpoint.clear()
        self.assertEqual(self._checkpoint.data, None)
 def test_get_item(self):
     cp = DataCheckpoint()
     cp.append('abc')
     self._checkpoint.add_checkpoint(cp)
     self.assertEqual(self._checkpoint[0].data, 'abc')
 def test_trigger_update(self):
     update = DataCheckpoint()
     update.append('abc')
     self._parent.trigger_update({'no-parent':update})
     # [0][0] to get first non-keyword argument, [0] to get Checkpoint for first parent
     self.assertEquals(self._transition._do_transition.call_args[0][0][0].data, 'abc')
 def test_trigger_update(self):
     update = DataCheckpoint()
     update.append('abc')
     self._transition.trigger_update({'no-parent':update})
     self._transition._do_transition.assert_called_once_with((update,))