'Test create_folder when child already present.'

def test_create_folder_already_present(self):

    parent_folder = mock.sentinel.parent_folder
    child_name = 'child_folder'
    prop_val = mock.Mock()
    child_entity_1 = mock.Mock()
    child_entity_1._type = 'Folder'
    child_entity_1_name = 'SomeOtherName'
    child_entity_2 = mock.Mock()
    child_entity_2._type = 'Folder'
    child_entity_2_name = 'AnotherName'
    child_entity_3 = mock.Mock()
    child_entity_3._type = 'Folder'
    child_entity_3_name = child_name
    prop_val.ManagedObjectReference = [child_entity_1, child_entity_2, child_entity_3]
    session = fake.FakeSession()
    with mock.patch.object(session, '_call_method', side_effect=[prop_val, child_entity_1_name, child_entity_2_name, child_entity_3_name]):
        ret = vm_util.create_folder(session, parent_folder, child_name)
        self.assertEqual(child_entity_3, ret)
        expected_invoke_api = [mock.call(vutil, 'get_object_property', parent_folder, 'childEntity'), mock.call(vutil, 'get_object_property', child_entity_1, 'name'), mock.call(vutil, 'get_object_property', child_entity_2, 'name'), mock.call(vutil, 'get_object_property', child_entity_3, 'name')]
        self.assertEqual(expected_invoke_api, session._call_method.mock_calls)
