Skip to content
This repository was archived by the owner on Apr 7, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions cfme/infrastructure/virtual_machines.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

from cfme.common import BaseLoggedInPage
from cfme.common import ComparableMixin
from cfme.common import CompareView
from cfme.common import TimelinesView
from cfme.common.provider_views import TemplatesCompareView
from cfme.common.vm import Template
Expand Down Expand Up @@ -491,7 +492,7 @@ class InfraVmSnapshotAddView(InfraVmView):


class InfraVmGenealogyToolbar(View):
"""The toolbar on the genalogy page"""
"""The toolbar on the genealogy page"""
history = Dropdown(title='History')
reload = Button(title='Refresh this page')
edit_tags = Button(title='Edit Tags for this VM')
Expand All @@ -512,6 +513,24 @@ def is_displayed(self):
return self.in_infra_vms and self.title.text == expected_title


class InfraVmCompareToolbar(View):
"""The toolbar on the compare page"""
all = Button(title='All Attributes')
different = Button(title='Attributes with different values')
same = Button(title='Attributes with same values')


class InfraVmCompareView(CompareView):
@property
def is_displayed(self):
title = "Compare VM or Template"
return (self.logged_in_as_current_user and
self.title.text == title and
self.navigation.currently_selected == ['Compute',
'Infrastructure', 'Virtual Machines']
)


class VMDisk(
namedtuple('VMDisk', ['filename', 'size', 'size_unit', 'type', 'mode'])):
"""Represents a single VM disk
Expand Down Expand Up @@ -1404,8 +1423,6 @@ def compare(self, *objects, **kwargs):
attributes: `all`, `different` or `same`. Default: `all`.
mode: `exists` or `details`. Default: `exists`."""
sections = kwargs.get('sections')
attributes = kwargs.get('attributes', 'all').lower()
mode = kwargs.get('mode', 'exists').lower()
assert len(objects) >= 2, 'You must specify at least two objects'
objects = [o.name if isinstance(o, (InfraVm, InfraTemplate)) else o for o in objects]
view = self.navigate()
Expand All @@ -1414,17 +1431,20 @@ def compare(self, *objects, **kwargs):
path = find_path(view.tree, obj)
view.tree.check_node(*path)
view.toolbar.compare.click()
view.flash.assert_no_errors()
compare_view = self.obj.create_view(InfraVmCompareView, wait=20)
compare_view.flash.assert_no_error()
# COMPARE PAGE
compare_view = self.obj.create_view('Compare')

if sections is not None:
list(map(lambda path: compare_view.tree.check_node(*path), sections))
compare_view.apply.click()
compare_view.flash.assert_no_errors()
# Set requested attributes sets
getattr(compare_view.toolbar, self.attr_mapping[attributes]).click()
getattr(compare_view.toolbar, "all_attributes").click()
# Set the requested mode
getattr(compare_view.toolbar, self.mode_mapping[mode]).click()
getattr(compare_view.toolbar, "exists_mode").click()

return compare_view

@property
def tree(self):
Expand Down
33 changes: 30 additions & 3 deletions cfme/tests/cloud_infra_common/test_genealogy.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import fauxfactory
import pytest
from wait_for import wait_for

from cfme import test_requirements
from cfme.cloud.provider import CloudProvider
from cfme.common.provider import BaseProvider
from cfme.containers.provider.openshift import OpenshiftProvider
from cfme.infrastructure.provider.rhevm import RHEVMProvider
from cfme.infrastructure.provider.scvmm import SCVMMProvider
from cfme.infrastructure.provider.virtualcenter import VMwareProvider
from cfme.markers.env_markers.provider import providers
from cfme.utils.appliance.implementations.ui import navigate_to
from cfme.utils.generators import random_vm_name
from cfme.utils.log import logger
from cfme.utils.providers import ProviderFilter

Expand All @@ -22,6 +26,29 @@
scope='module'),
test_requirements.genealogy
]


@pytest.fixture
def create_vm_with_clone(request, create_vm, provider, appliance):
"""Fixture to provision a VM and clone it"""
first_name = fauxfactory.gen_alphanumeric()
last_name = fauxfactory.gen_alphanumeric()
email = "{first_name}.{last_name}@test.com"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you want to use f-sting here. Other thought fauxfactory.gen_email()

provision_type = 'VMware'

vm_name = random_vm_name(context=None, max_length=15)

create_vm.clone_vm(email, first_name, last_name, vm_name, provision_type)
vm2 = appliance.collections.infra_vms.instantiate(vm_name, provider)
wait_for(lambda: vm2.exists, timeout=120)

@request.addfinalizer
def _cleanup():
vm2.cleanup_on_provider()
provider.refresh_provider_relationships()

return create_vm, vm2

# uncollected above in pytest_generate_tests
@pytest.mark.parametrize("from_edit", [True, False], ids=["via_edit", "via_summary"])
@pytest.mark.uncollectif(lambda provider, from_edit:
Expand Down Expand Up @@ -72,9 +99,9 @@ def test_vm_genealogy_detected(
f"{small_template.name} is not in {create_vm.name}'s ancestors"


@pytest.mark.manual
@pytest.mark.provider([VMwareProvider])
@pytest.mark.tier(1)
def test_compare_button_enabled():
def test_compare_button_enabled(create_vm_with_clone, soft_assert):
"""
Test that compare button is enabled

Expand All @@ -97,7 +124,7 @@ def test_compare_button_enabled():
Bugzilla:
1694712
"""
pass
assert create_vm_with_clone[0].genealogy.compare(*create_vm_with_clone).is_displayed


@pytest.mark.manual
Expand Down