125
120
self.assertEqual(conflicts.ConflictList([]), tree.conflicts())
128
class TestPerConflict(tests.TestCase):
130
scenarios = scenarios.multiply_scenarios(vary_by_conflicts())
132
def test_stringification(self):
133
text = unicode(self.conflict)
134
self.assertContainsString(text, self.conflict.path)
135
self.assertContainsString(text.lower(), "conflict")
136
self.assertContainsString(repr(self.conflict),
137
self.conflict.__class__.__name__)
123
class TestConflictStanzas(tests.TestCase):
139
125
def test_stanza_roundtrip(self):
141
o = conflicts.Conflict.factory(**p.as_stanza().as_dict())
142
self.assertEqual(o, p)
144
self.assertIsInstance(o.path, unicode)
146
if o.file_id is not None:
147
self.assertIsInstance(o.file_id, str)
149
conflict_path = getattr(o, 'conflict_path', None)
150
if conflict_path is not None:
151
self.assertIsInstance(conflict_path, unicode)
153
conflict_file_id = getattr(o, 'conflict_file_id', None)
154
if conflict_file_id is not None:
155
self.assertIsInstance(conflict_file_id, str)
126
# write and read our example stanza.
127
stanza_iter = example_conflicts.to_stanzas()
128
processed = conflicts.ConflictList.from_stanzas(stanza_iter)
129
for o, p in zip(processed, example_conflicts):
130
self.assertEqual(o, p)
132
self.assertIsInstance(o.path, unicode)
134
if o.file_id is not None:
135
self.assertIsInstance(o.file_id, str)
137
conflict_path = getattr(o, 'conflict_path', None)
138
if conflict_path is not None:
139
self.assertIsInstance(conflict_path, unicode)
141
conflict_file_id = getattr(o, 'conflict_file_id', None)
142
if conflict_file_id is not None:
143
self.assertIsInstance(conflict_file_id, str)
157
145
def test_stanzification(self):
158
stanza = self.conflict.as_stanza()
159
if 'file_id' in stanza:
160
# In Stanza form, the file_id has to be unicode.
161
self.assertStartsWith(stanza['file_id'], u'\xeed')
162
self.assertStartsWith(stanza['path'], u'p\xe5th')
163
if 'conflict_path' in stanza:
164
self.assertStartsWith(stanza['conflict_path'], u'p\xe5th')
165
if 'conflict_file_id' in stanza:
166
self.assertStartsWith(stanza['conflict_file_id'], u'\xeed')
169
class TestConflictList(tests.TestCase):
171
def test_stanzas_roundtrip(self):
172
stanzas_iter = example_conflicts.to_stanzas()
173
processed = conflicts.ConflictList.from_stanzas(stanzas_iter)
174
self.assertEqual(example_conflicts, processed)
176
def test_stringification(self):
177
for text, o in zip(example_conflicts.to_strings(), example_conflicts):
178
self.assertEqual(text, unicode(o))
146
for stanza in example_conflicts.to_stanzas():
147
if 'file_id' in stanza:
148
# In Stanza form, the file_id has to be unicode.
149
self.assertStartsWith(stanza['file_id'], u'\xeed')
150
self.assertStartsWith(stanza['path'], u'p\xe5th')
151
if 'conflict_path' in stanza:
152
self.assertStartsWith(stanza['conflict_path'], u'p\xe5th')
153
if 'conflict_file_id' in stanza:
154
self.assertStartsWith(stanza['conflict_file_id'], u'\xeed')
181
157
# FIXME: The shell-like tests should be converted to real whitebox tests... or