def policy_for_testing(appliance, full_template_vm_modscope, provider, ansible_action):
    vm = full_template_vm_modscope
    policy = appliance.collections.policies.create(
        VMControlPolicy,
        fauxfactory.gen_alpha(),
        scope="fill_field(VM and Instance : Name, INCLUDES, {})".format(vm.name)
    )
    policy.assign_actions_to_event("Tag Complete", [ansible_action.description])
    policy_profile = appliance.collections.policy_profiles.create(
        fauxfactory.gen_alpha(), policies=[policy])
    provider.assign_policy_profiles(policy_profile.description)
    yield

    if policy.exists:
        policy.assign_events()
        provider.unassign_policy_profiles(policy_profile.description)
        policy_profile.delete()
        policy.delete()