/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.1.2 by Martin Pool
Import testsweet module adapted from bzr.
1
# Copyright (C) 2005 by Canonical Ltd
2
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
17
18
19
20
"""test case for knit/weave algorithm"""
21
22
23
from testsweet import TestBase
24
from knit import Knit
25
26
27
# texts for use in testing
0.1.3 by Martin Pool
Change storage of texts for testing
28
TEXT_0 = ["Hello world"]
29
TEXT_1 = ["Hello world",
30
          "A second line"]
0.1.2 by Martin Pool
Import testsweet module adapted from bzr.
31
32
33
class Easy(TestBase):
34
    def runTest(self):
35
        k = Knit()
36
37
38
class StoreText(TestBase):
39
    """Store and retrieve a simple text."""
40
    def runTest(self):
41
        k = Knit()
0.1.4 by Martin Pool
Start indexing knits by both integer and version string.
42
        idx = k.add(TEXT_0)
43
        self.assertEqual(k.get(idx), TEXT_0)
44
        self.assertEqual(idx, 0)
0.1.2 by Martin Pool
Import testsweet module adapted from bzr.
45
46
0.1.7 by Martin Pool
Add trivial annotate text
47
48
class AnnotateOne(TestBase):
49
    def runTest(self):
50
        k = Knit()
51
        k.add(TEXT_0)
52
        self.assertEqual(k.annotate(0),
53
                         [(0, TEXT_0[0])])
54
55
0.1.5 by Martin Pool
Add test for storing two text versions.
56
class StoreTwo(TestBase):
57
    def runTest(self):
58
        k = Knit()
59
60
        idx = k.add(TEXT_0)
61
        self.assertEqual(idx, 0)
62
63
        idx = k.add(TEXT_1)
64
        self.assertEqual(idx, 1)
65
66
        self.assertEqual(k.get(0), TEXT_0)
67
        self.assertEqual(k.get(1), TEXT_1)
68
0.1.13 by Martin Pool
Knit structure now allows for versions to include the lines present in other
69
        k.dump(self.TEST_LOG)
70
71
72
class MatchedLine(TestBase):
73
    """Store a revision that adds one line to the original.
74
75
    Look at the annotations to make sure that the first line is matched
76
    and not stored repeatedly."""
77
    def runTest(self):
78
        return #################################### SKIPPED
79
        k = Knit()
80
81
        k.add(['line 1'])
82
        k.add(['line 1', 'line 2'])
83
84
        self.assertEqual(k.annotate(0),
85
                         [(0, 'line 1')])
86
87
        self.assertEqual(k.annotate(1),
88
                         [(0, 'line 1'),
89
                          (1, 'line 2')])
90
91
92
class IncludeVersions(TestBase):
93
    """Check texts that are stored across multiple revisions.
94
95
    Here we manually create a knit with particular encoding and make
96
    sure it unpacks properly.
97
98
    Text 0 includes nothing; text 1 includes text 0 and adds some
99
    lines.
100
    """
101
102
    def runTest(self):
103
        k = Knit()
104
105
        k._v = [((),), ((0,),)]
106
        k._l = [(0, "first line"),
107
                (1, "second line")]
108
109
        self.assertEqual(k.get(1),
110
                         ["first line",
111
                          "second line"])
112
113
        self.assertEqual(k.get(0),
114
                         ["first line"])
115
116
        k.dump(self.TEST_LOG)
117
0.1.5 by Martin Pool
Add test for storing two text versions.
118
0.1.2 by Martin Pool
Import testsweet module adapted from bzr.
119
def testknit():
120
    import testsweet
121
    from unittest import TestSuite, TestLoader
122
    import testknit
123
124
    tl = TestLoader()
125
    suite = TestSuite()
126
    suite.addTest(tl.loadTestsFromModule(testknit))
127
    
128
    return testsweet.run_suite(suite)
129
130
131
if __name__ == '__main__':
132
    import sys
133
    sys.exit(testknit())
134