]> scripts.mit.edu Git - wizard.git/blob - wizard/tests/resolve_test.py
Remove string exception from remaster.
[wizard.git] / wizard / tests / resolve_test.py
1 import unittest
2
3 from wizard import resolve
4
5 class TestResolve(unittest.TestCase):
6
7     def test_resolve_simple(self):
8         contents = """
9 foo
10 bar
11 <<<<<<< HEAD
12 baz
13 |||||||
14 bal
15 =======
16 boo
17 >>>>>>> upstream
18 bing
19 """
20         spec = """
21 <<<<<<<
22 baz
23 =======
24 boo
25 >>>>>>>
26 """
27         result = [0]
28         self.assertEqual(resolve.resolve(contents, spec, result), """
29 foo
30 bar
31 boo
32 bing
33 """)
34
35     def test_resolve_simple_constrained(self):
36         contents = """
37 1
38 <<<<<<< HEAD
39 2.1
40 |||||||
41 2
42 =======
43 2.a
44 >>>>>>> upstream
45 3
46 """
47         spec = """
48 <<<<<<< HEAD
49 2.1
50 |||||||
51 2
52 =======
53 2.a
54 >>>>>>> upstream
55 """
56         result = [0]
57         self.assertEqual(resolve.resolve(contents, spec, result), """
58 1
59 2.a
60 3
61 """)
62
63     def test_resolve_wildcard(self):
64         contents = """
65 foo
66 bar
67 <<<<<<< HEAD
68 common
69 uncommon
70 still uncommon
71
72 |||||||
73 something else
74 =======
75 transformed common
76 >>>>>>> 456ef127bf8531bb363b1195172c71bce3747ae7
77 baz
78 """
79
80         spec = """
81 <<<<<<<
82 common
83 ***1***
84 =======
85 transformed common
86 >>>>>>>
87 """
88
89         result = [0, 1]
90         self.assertEqual(resolve.resolve(contents, spec, result), """
91 foo
92 bar
93 transformed common
94 uncommon
95 still uncommon
96
97 baz
98 """)
99
100     def test_resolve_user(self):
101         contents = """
102 top
103 <<<<<<<
104 bar
105 the user is right
106 baz
107 |||||||
108 something wonderful
109 =======
110 blah blah
111 >>>>>>>
112 bottom
113 <<<<<<<
114 Unrelated conflict
115 |||||||
116 something conflicty
117 =======
118 Unrelated conflicts
119 >>>>>>>"""
120         spec = """
121 <<<<<<<
122 ***1***
123 the user is right
124 ***2***
125 =======
126 blah blah
127 >>>>>>>
128 """
129         result = [-1]
130         self.assertEqual(resolve.resolve(contents, spec, result), """
131 top
132 bar
133 the user is right
134 baz
135 bottom
136 <<<<<<<
137 Unrelated conflict
138 |||||||
139 something conflicty
140 =======
141 Unrelated conflicts
142 >>>>>>>""")
143
144     def test_resolve_multi_var(self):
145         contents = """
146 top
147 <<<<<<<
148 the user is right
149 this is ours
150 more user stuff
151 this is ours
152 |||||||
153 Something special?
154 =======
155 this is kept, but variable
156 this is not kept
157 >>>>>>>
158 bottom
159 <<<<<<<
160 unrelated conflict
161 |||||||
162 original text of unrelated conflict
163 =======
164 unrelated conflicts
165 >>>>>>>
166 """
167         spec = """
168 <<<<<<<
169 ***1***
170 this is ours
171 ***2***
172 this is ours
173 =======
174 ***3***
175 this is not kept
176 >>>>>>>
177 """
178         result = [3, 1, 2]
179         self.assertEqual(resolve.resolve(contents, spec, result), """
180 top
181 this is kept, but variable
182 the user is right
183 more user stuff
184 bottom
185 <<<<<<<
186 unrelated conflict
187 |||||||
188 original text of unrelated conflict
189 =======
190 unrelated conflicts
191 >>>>>>>
192 """)
193
194     def test_resolve_multi_simple(self):
195         contents = """
196 bar
197 <<<<<<< HEAD
198 baz
199 |||||||
200 bollocks
201 =======
202 boo
203 >>>>>>> upstream
204 bing
205 <<<<<<< HEAD
206 oh?
207 |||||||
208 puntful
209 =======
210 bad match
211 >>>>>>> upstream
212 """
213         spec = """
214 <<<<<<<
215 ***1***
216 =======
217 bad match
218 >>>>>>>
219 """
220         result = [-1]
221         self.assertEqual(resolve.resolve(contents, spec, result), """
222 bar
223 <<<<<<< HEAD
224 baz
225 |||||||
226 bollocks
227 =======
228 boo
229 >>>>>>> upstream
230 bing
231 oh?
232 """)
233
234 def test_is_conflict():
235     assert not resolve.is_conflict("foobar\nbar")
236     assert resolve.is_conflict("bar\n<<<<<<< HEAD\n=======\n>>>>>>> abcd\nbar")