33
33
get_transport(self.get_url()),
36
def get_target(self, name='target'):
36
def get_target(self, name='target', create=True):
37
37
""""Get an empty versioned file to join into."""
38
38
return self.versionedfile_factory_to(name,
39
39
get_transport(self.get_url()),
42
42
def test_join(self):
43
43
f1 = self.get_source()
317
317
target = self.get_target()
318
318
target.join(source, version_ids=['select_me'])
319
319
self.assertEqual(['inherit_me', 'select_me'], target.versions())
321
def test_join_odd_records(self):
322
# this tests that joining the 1st, 3rd and 5th records and not the
323
# 2nd and 4th works, particularly after reopening the file.
324
# this test is designed to test versioned files that perform
325
# optimisations on the join. Grabbing partial data and reopening the
326
# file make it likely to trigger a fault.
327
source = self.get_source()
328
source.add_lines('1', [], ['1st\n'])
329
source.add_lines('2', [], ['2nd\n'])
330
source.add_lines('3', ['1'], ['1st\n', '2nd\n'])
331
source.add_lines('4', ['2'], ['1st\n'])
332
source.add_lines('5', ['3'], ['1st\n', '2nd\n', '3rd\n'])
333
target = self.get_target()
334
target.join(source, version_ids=['1', '3', '5'])
335
target = self.get_target(create=False)
336
self.assertEqual(set(['1', '3', '5']), set(target.versions()))
337
self.assertEqual(3, len(target.versions()))
338
self.assertEqual(['1st\n'], target.get_lines('1'))
339
self.assertEqual(['1st\n', '2nd\n'], target.get_lines('3'))
340
self.assertEqual(['1st\n', '2nd\n', '3rd\n'], target.get_lines('5'))