@@ 219-235 (lines=17) @@ | ||
216 | actual = [item.level for item in document.items] |
|
217 | self.assertListEqual(expected, actual) |
|
218 | ||
219 | @patch('doorstop.settings.REORDER', True) |
|
220 | @patch('doorstop.settings.REVIEW_NEW_ITEMS', False) |
|
221 | def test_validate_with_reordering(self): |
|
222 | """Verify a document's order is corrected during validation.""" |
|
223 | document = core.Document.new(None, |
|
224 | EMPTY, FILES, |
|
225 | prefix='TMP') |
|
226 | document.add_item(level='1.0', reorder=False) |
|
227 | document.add_item(level='1.1', reorder=False) |
|
228 | document.add_item(level='1.2.0', reorder=False) |
|
229 | document.add_item(level='1.2.5', reorder=False) |
|
230 | document.add_item(level='3.2.1', reorder=False) |
|
231 | document.add_item(level='3.3', reorder=False) |
|
232 | self.assertTrue(document.validate()) |
|
233 | expected = [(1, 0), (1, 1), (1, 2, 0), (1, 2, 1), (2, 1, 1), (2, 2)] |
|
234 | actual = [item.level for item in document.items] |
|
235 | self.assertListEqual(expected, actual) |
|
236 | ||
237 | ||
238 | class TestTree(unittest.TestCase): |
|
@@ 203-217 (lines=15) @@ | ||
200 | self.assertListEqual(expected, actual) |
|
201 | self.assertEqual((1, 0), item.level) |
|
202 | ||
203 | def test_reorder_with_start(self): |
|
204 | """Verify a document's order can be corrected with a given start.""" |
|
205 | document = core.Document.new(None, |
|
206 | EMPTY, FILES, |
|
207 | prefix='TMP') |
|
208 | document.add_item(level='2.0', reorder=False) |
|
209 | document.add_item(level='2.1', reorder=False) |
|
210 | document.add_item(level='2.1', reorder=False) |
|
211 | document.add_item(level='2.5', reorder=False) |
|
212 | document.add_item(level='4.0', reorder=False) |
|
213 | document.add_item(level='4.7', reorder=False) |
|
214 | document.reorder(start=(1, 0)) |
|
215 | expected = [(1, 0), (1, 1), (1, 2), (1, 3), (2, 0), (2, 1)] |
|
216 | actual = [item.level for item in document.items] |
|
217 | self.assertListEqual(expected, actual) |
|
218 | ||
219 | @patch('doorstop.settings.REORDER', True) |
|
220 | @patch('doorstop.settings.REVIEW_NEW_ITEMS', False) |
|
@@ 173-187 (lines=15) @@ | ||
170 | self.assertEqual((1, 0), item_1_0.level) |
|
171 | self.assertEqual((1, 1), item_1_1.level) |
|
172 | ||
173 | def test_reorder(self): |
|
174 | """Verify a document's order can be corrected.""" |
|
175 | document = core.Document.new(None, |
|
176 | EMPTY, FILES, |
|
177 | prefix='TMP') |
|
178 | document.add_item(level='2.0', reorder=False) |
|
179 | document.add_item(level='2.1', reorder=False) |
|
180 | document.add_item(level='2.1', reorder=False) |
|
181 | document.add_item(level='2.5', reorder=False) |
|
182 | document.add_item(level='4.5', reorder=False) |
|
183 | document.add_item(level='4.7', reorder=False) |
|
184 | document.reorder() |
|
185 | expected = [(2, 0), (2, 1), (2, 2), (2, 3), (3, 1), (3, 2)] |
|
186 | actual = [item.level for item in document.items] |
|
187 | self.assertListEqual(expected, actual) |
|
188 | ||
189 | def test_reorder_with_keep(self): |
|
190 | """Verify a document's order can be corrected with a kept level.""" |