23
23
from bzrlib.errors import KnitError, RevisionAlreadyPresent, NoSuchFile
24
24
from bzrlib.knit import (
27
28
KnitAnnotateFactory,
29
30
from bzrlib.osutils import split_lines
30
from bzrlib.tests import TestCaseWithTransport
31
from bzrlib.tests import TestCase, TestCaseWithTransport
31
32
from bzrlib.transport import TransportLogger, get_transport
32
33
from bzrlib.transport.memory import MemoryTransport
33
34
from bzrlib.weave import Weave
37
class KnitContentTests(TestCase):
39
def test_constructor(self):
40
content = KnitContent([])
43
content = KnitContent([])
44
self.assertEqual(content.text(), [])
46
content = KnitContent([("origin1", "text1"), ("origin2", "text2")])
47
self.assertEqual(content.text(), ["text1", "text2"])
49
def test_annotate(self):
50
content = KnitContent([])
51
self.assertEqual(content.annotate(), [])
53
content = KnitContent([("origin1", "text1"), ("origin2", "text2")])
54
self.assertEqual(content.annotate(),
55
[("origin1", "text1"), ("origin2", "text2")])
57
def test_annotate_iter(self):
58
content = KnitContent([])
59
it = content.annotate_iter()
60
self.assertRaises(StopIteration, it.next)
62
content = KnitContent([("origin1", "text1"), ("origin2", "text2")])
63
it = content.annotate_iter()
64
self.assertEqual(it.next(), ("origin1", "text1"))
65
self.assertEqual(it.next(), ("origin2", "text2"))
66
self.assertRaises(StopIteration, it.next)
69
content = KnitContent([("origin1", "text1"), ("origin2", "text2")])
71
self.assertIsInstance(copy, KnitContent)
72
self.assertEqual(copy.annotate(),
73
[("origin1", "text1"), ("origin2", "text2")])
75
def test_line_delta(self):
76
content1 = KnitContent([("", "a"), ("", "b")])
77
content2 = KnitContent([("", "a"), ("", "a"), ("", "c")])
78
self.assertEqual(content1.line_delta(content2),
79
[(1, 2, 2, [("", "a"), ("", "c")])])
81
def test_line_delta_iter(self):
82
content1 = KnitContent([("", "a"), ("", "b")])
83
content2 = KnitContent([("", "a"), ("", "a"), ("", "c")])
84
it = content1.line_delta_iter(content2)
85
self.assertEqual(it.next(), (1, 2, 2, [("", "a"), ("", "c")]))
86
self.assertRaises(StopIteration, it.next)
36
88
class KnitTests(TestCaseWithTransport):
37
89
"""Class containing knit test helper routines."""