def test_upload_multiple_sources(self): self.assertEqual(self.recommended_size % 8, 0) unit_part_size = int(self.recommended_size / 8) uneven_part_size = 3 * unit_part_size sources = [ UploadSource(uneven_part_size) for i in range(8) ] self.verify_emerge_plan_for_write_intents( WriteIntent.wrap_sources_iterator(sources), [ part([ sources[0], sources[1], (sources[2], 0, 2 * unit_part_size), ]), part([ (sources[2], 2 * unit_part_size, unit_part_size), sources[3], sources[4], (sources[5], 0, unit_part_size), ]), part([ (sources[5], unit_part_size, 2 * unit_part_size), sources[6], sources[7], ]), ], )
def test_copy_then_small_copy(self): source_copy = CopySource(self.recommended_size) source_small_copy = CopySource(self.min_size - 1) write_intents = WriteIntent.wrap_sources_iterator([source_copy, source_small_copy]) self.verify_emerge_plan_for_write_intents( write_intents, [ part(source_copy), part([source_small_copy]), # this means: download and then upload ], )
def test_simple_concatenate(self): sources = [ CopySource(self.recommended_size), UploadSource(self.recommended_size), CopySource(self.recommended_size), UploadSource(self.recommended_size), ] self.verify_emerge_plan_for_write_intents( WriteIntent.wrap_sources_iterator(sources), [part(source) for source in sources], )
def test_upload_small_copy_then_copy(self): source_upload = UploadSource(self.recommended_size) source_small_copy = CopySource(self.min_size - 1) source_copy = CopySource(self.recommended_size) write_intents = WriteIntent.wrap_sources_iterator([source_upload, source_small_copy, source_copy]) self.verify_emerge_plan_for_write_intents( write_intents, [ part([ source_upload, source_small_copy, ]), part(source_copy), ] )
def test_small_copy_then_copy(self): self.assertGreater(self.min_size, MEGABYTE) source_small_copy = CopySource(self.min_size - MEGABYTE) source_copy = CopySource(self.recommended_size) write_intents = WriteIntent.wrap_sources_iterator([source_small_copy, source_copy]) self.verify_emerge_plan_for_write_intents( write_intents, [ part([ source_small_copy, (source_copy, 0, MEGABYTE), ]), part(source_copy, MEGABYTE, self.recommended_size - MEGABYTE) ], )
def test_small_upload_not_enough_copy_then_upload(self): self.assertGreater(self.min_size, 2 * MEGABYTE) source_small_upload = UploadSource(self.min_size - 2 * MEGABYTE) source_copy = CopySource(self.min_size + MEGABYTE) source_upload = UploadSource(self.recommended_size) write_intents = WriteIntent.wrap_sources_iterator( [source_small_upload, source_copy, source_upload] ) small_parts_len = source_small_upload.get_content_length() + source_copy.get_content_length() source_upload_split_offset = self.recommended_size - small_parts_len self.verify_emerge_plan_for_write_intents( write_intents, [ part([ source_small_upload, source_copy, (source_upload, 0, source_upload_split_offset), ]), part(source_upload, source_upload_split_offset, small_parts_len), ], )