Exemple #1
0
    def test_action__bad(self):
        h = TextHistory()
        action = InsertAction(pos=0,
                              text='abc',
                              from_version=10,
                              to_version=10)

        with self.assertRaises(ValueError):
            h.action(action)
Exemple #2
0
    def test_optimise_replace(self):
        h = TextHistory()
        h.insert('abcdefgh')
        h.replace('abc', 0)
        h.replace('woa', 0)

        actions = h.get_actions()
        self.assertEqual(2, len(actions))
        th = TextHistory()
        for act in actions:
            th.action(act)
        self.assertEqual(h.text, th.text)
Exemple #3
0
    def test_optimise_del(self):
        h = TextHistory()
        h.insert('abcdefgh')
        h.delete(2, 2)
        h.delete(2, 3)

        actions = h.get_actions()
        self.assertEqual(2, len(actions))
        th = TextHistory()
        for act in actions:
            th.action(act)
        self.assertEqual(h.text, th.text)
Exemple #4
0
    def test_action(self):
        h = TextHistory()
        action = InsertAction(pos=0, text='abc', from_version=0, to_version=10)

        self.assertEqual(10, h.action(action))
        self.assertEqual('abc', h.text)
        self.assertEqual(10, h.version)