20
from bzrlib.tests import TestCaseWithTransport
20
from bzrlib.tests import TestCaseWithTransport, TestCase
21
21
from bzrlib.branch import Branch
22
from bzrlib.conflicts import restore
22
from bzrlib.conflicts import restore, stanza_conflicts, conflict_stanzas
23
23
from bzrlib.errors import NotConflicted
25
26
# TODO: Test commit with some added, and added-but-missing files
26
27
# RBC 20060124 is that not tested in test_commit.py ?
30
('contents conflict', 'ida', 'patha'),
31
('text conflict', None, 'patha'),
32
('path conflict', 'idb', 'pathb'),
33
('duplicate id', 'Unversioned existing file', 'pathc', 'idc', 'pathc2',
35
('duplicate', 'Moved existing file to', 'pathdd.moved', 'idd', 'pathd',
37
('parent loop', 'Cancelled move', 'pathe', None, 'path2e', 'id2e'),
38
('unversioned parent', 'Versioned directory', 'pathf', 'idf'),
39
('missing parent', 'Not deleting', 'pathg', 'idg'),
28
43
class TestConflicts(TestCaseWithTransport):
30
45
def test_conflicts(self):
49
64
assert not os.path.lexists('hello.sploo')
50
65
self.assertRaises(NotConflicted, restore, 'hello')
51
66
self.assertRaises(NotConflicted, restore, 'hello.sploo')
69
class TestConflictStanzas(TestCase):
70
def test_stanza_roundtrip(self):
71
processed = list(stanza_conflicts(conflict_stanzas(example_conflicts)))
72
for o,p in zip(processed, example_conflicts):
73
self.assertEqual(o, p)
75
def test_stanzification(self):
76
for stanza in conflict_stanzas(example_conflicts):
78
self.assertStartsWith(stanza['file_id'], 'id')
81
self.assertStartsWith(stanza['path'], 'path')
83
self.assertStartsWith(stanza['conflict_file_id'], 'id')
84
self.assertStartsWith(stanza['conflict_file_path'], 'path')