207
207
self.assertRaises(errors.RevisionNotPresent, vf.get_lines,
210
def test_add_lines_nostoresha(self):
211
"""When nostore_sha is supplied using old content raises."""
213
empty_text = ('a', [])
214
sample_text_nl = ('b', ["foo\n", "bar\n"])
215
sample_text_no_nl = ('c', ["foo\n", "bar"])
217
for version, lines in (empty_text, sample_text_nl, sample_text_no_nl):
218
sha, _, _ = vf.add_lines(version, [], lines)
220
# we now have a copy of all the lines in the vf.
221
for sha, (version, lines) in zip(
222
shas, (empty_text, sample_text_nl, sample_text_no_nl)):
223
self.assertRaises(errors.ExistingContent,
224
vf.add_lines, version + "2", [], lines,
226
# and no new version should have been added.
227
self.assertRaises(errors.RevisionNotPresent, vf.get_lines,
230
def test_add_lines_nostoresha(self):
231
"""When nostore_sha is supplied using old content raises."""
233
empty_text = ('a', [])
234
sample_text_nl = ('b', ["foo\n", "bar\n"])
235
sample_text_no_nl = ('c', ["foo\n", "bar"])
237
for version, lines in (empty_text, sample_text_nl, sample_text_no_nl):
238
sha, _, _ = vf.add_lines(version, [], lines)
240
# we now have a copy of all the lines in the vf.
241
# is the test applicable to this vf implementation?
243
vf.add_lines_with_ghosts('d', [], [])
244
except NotImplementedError:
245
raise TestSkipped("add_lines_with_ghosts is optional")
246
for sha, (version, lines) in zip(
247
shas, (empty_text, sample_text_nl, sample_text_no_nl)):
248
self.assertRaises(errors.ExistingContent,
249
vf.add_lines_with_ghosts, version + "2", [], lines,
251
# and no new version should have been added.
252
self.assertRaises(errors.RevisionNotPresent, vf.get_lines,
255
210
def test_add_lines_return_value(self):
256
211
# add_lines should return the sha1 and the text size.
257
212
vf = self.get_file()