Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

Commit

Permalink
[1LP][RFR] New Test: Checks moving VMWare vm to custom vm folder (#9230)
Browse files Browse the repository at this point in the history
* New Test: This test case checks moving VMWare vm to custom folder via automate method

* Updated with requested changes
  • Loading branch information
Ganesh Hubale authored and izapolsk committed Dec 27, 2019
1 parent 92aa330 commit 60b048f
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions cfme/tests/automate/test_common_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
import fauxfactory
import pytest
from widgetastic.utils import partial_match
from widgetastic_patternfly import CandidateNotFound

from cfme import test_requirements
from cfme.automate.simulation import simulate
from cfme.infrastructure.provider import InfraProvider
from cfme.infrastructure.provider.rhevm import RHEVMProvider
from cfme.infrastructure.provider.virtualcenter import VMwareProvider
from cfme.infrastructure.virtual_machines import InfraVmSummaryView
from cfme.markers.env_markers.provider import ONE
from cfme.provisioning import do_vm_provisioning
Expand Down Expand Up @@ -320,3 +322,71 @@ def _finalize():
assert provision_request.is_succeeded(
method="ui"
), f"Provisioning failed: {provision_request.row.last_message.text}"


@pytest.fixture(scope="function")
def vm_folder(provider):
"""Create Vm folder on VMWare provider"""
folder = provider.mgmt.create_folder(fauxfactory.gen_alphanumeric(
start="test_folder_", length=20)
)
yield folder
fd = folder.Destroy()
wait_for(lambda: fd.info.state == 'success', delay=10, timeout=150)


@pytest.mark.tier(3)
@pytest.mark.ignore_stream("5.10")
@pytest.mark.provider([VMwareProvider], selector=ONE)
@pytest.mark.meta(automates=[1716858])
def test_move_vm_into_folder(appliance, vm_folder, testing_vm, custom_instance):
"""
Bugzilla:
1716858
Polarion:
assignee: ghubale
casecomponent: Automate
initialEstimate: 1/4h
tags: automate
"""
script = dedent(
f"""
vm = $evm.vmdb('vm').find_by_name('{testing_vm.name}')
folder = $evm.vmdb('EmsFolder').find_by(:name => '{vm_folder.name}')
vm.move_into_folder(folder) unless folder.nil?
"""
)
instance = custom_instance(ruby_code=script)

view = navigate_to(testing_vm, "Details")
tree_path = view.sidebar.vmstemplates.tree.currently_selected

simulate(
appliance=appliance,
attributes_values={
"namespace": instance.klass.namespace.name,
"class": instance.klass.name,
"instance": instance.name,
},
message="create",
request="Call_Instance",
execute_methods=True,
)
# manipulate tree path. Remove folder - 'Templates' and append with vm_folder name
tree_path.pop()
tree_path.append(vm_folder.name)

# Navigating to Vms details page and checking folder of the Vm in accordion of CFME UI
view = navigate_to(testing_vm, "Details")

# Checking new folder appeared
def _check():
try:
view.sidebar.vmstemplates.tree.fill(tree_path)
return True
except CandidateNotFound:
return False

wait_for(lambda: _check, fail_func=view.browser.refresh, timeout=600, delay=5,
message="Waiting for vm folder name to appear")

0 comments on commit 60b048f

Please sign in to comment.