'Mock vim_util calls made by get_datastore.'

def _mock_get_datastore_calls(self, *datastores):

    datastores_i = [None]
    fake_ds_list = ['fake-ds']
    def fake_call_method(module, method, *args, **kwargs):
        if ((module == ds_util.vutil) and (method == 'get_object_property') and (args == ('fake-cluster', 'datastore'))):
            fake_ds_mor = fake.DataObject()
            fake_ds_mor.ManagedObjectReference = fake_ds_list
            return fake_ds_mor
        if ((module == ds_util.vim_util) and (method == 'get_properties_for_a_collection_of_objects') and (args[0] == 'Datastore') and (args[1] == fake_ds_list)):
            datastores_i[0] = iter(datastores)
            return next(datastores_i[0])
        if ((module == ds_util.vutil) and (method == 'continue_retrieval')):
            try:
                return next(datastores_i[0])
            except StopIteration:
                return None
        if ((method == 'continue_retrieval') or (method == 'cancel_retrieval')):
            return
        self.fail(('Unexpected    vim    call    in    get_datastore:    %s' % method))
    return mock.patch.object(self.session, '_call_method', side_effect=fake_call_method)
