def test_iterator(self):
        src_strings_array = [['src_{}_{}'.format(i, j) for j in range(4)]
                             for i in range(3)]
        dst_strings = ['dest_' + str(i) for i in range(3)]

        copy_objects_iterator = CopyObjectsIterator(
            _ConstrcutNameExpansionIteratorDestinationTupleIterator(
                src_strings_array, dst_strings), False)

        # Flatten the src dst arrays
        src_dst_strings = [
            (src, dst)
            for src_strings, dst in zip(src_strings_array, dst_strings)
            for src in src_strings
        ]

        for (src_string, dst_string) in src_dst_strings:
            copy_object_info = copy_objects_iterator.next()
            self.assertEquals(src_string,
                              copy_object_info.source_storage_url.object_name)
            self.assertEquals(dst_string,
                              copy_object_info.exp_dst_url.object_name)

        iterator_ended = False
        try:
            copy_objects_iterator.next()
        except StopIteration:
            iterator_ended = True

        self.assertTrue(iterator_ended)
    def test_iterator_metadata(self):
        src_strings_array = [['gs://bucket1'], ['source'], ['s3://bucket1']]
        dst_strings = ['gs://bucket2', 'dest', 'gs://bucket2']

        copy_objects_iterator = CopyObjectsIterator(
            _ConstrcutNameExpansionIteratorDestinationTupleIterator(
                src_strings_array, dst_strings), False)

        self.assertFalse(copy_objects_iterator.has_cloud_src)
        self.assertFalse(copy_objects_iterator.has_file_src)
        self.assertEquals(len(copy_objects_iterator.provider_types), 0)

        copy_objects_iterator.next()
        self.assertTrue(copy_objects_iterator.has_cloud_src)
        self.assertFalse(copy_objects_iterator.has_file_src)
        self.assertEquals(len(copy_objects_iterator.provider_types), 1)
        self.assertTrue('gs' in copy_objects_iterator.provider_types)

        copy_objects_iterator.next()
        self.assertTrue(copy_objects_iterator.has_cloud_src)
        self.assertTrue(copy_objects_iterator.has_file_src)
        self.assertEquals(len(copy_objects_iterator.provider_types), 2)
        self.assertTrue('file' in copy_objects_iterator.provider_types)
        self.assertFalse(copy_objects_iterator.is_daisy_chain)

        copy_objects_iterator.next()
        self.assertEquals(len(copy_objects_iterator.provider_types), 3)
        self.assertTrue('s3' in copy_objects_iterator.provider_types)
        self.assertTrue(copy_objects_iterator.is_daisy_chain)