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

Commit

Permalink
Merge pull request #10295 from jaryn/only_fix_datastores
Browse files Browse the repository at this point in the history
[1LP][RFR] Fix datastore SmartState analysis tests
  • Loading branch information
mshriver authored Sep 3, 2020
2 parents 895f5ec + 4c661d8 commit 672e37b
Show file tree
Hide file tree
Showing 8 changed files with 303 additions and 243 deletions.
173 changes: 173 additions & 0 deletions cfme/common/datastore_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
from lxml.html import document_fromstring
from widgetastic.widget import Text
from widgetastic.widget import View
from widgetastic_patternfly import Accordion
from widgetastic_patternfly import Dropdown

from cfme.common import BaseLoggedInPage
from cfme.common.vm_views import VMEntities
from widgetastic_manageiq import BaseEntitiesView
from widgetastic_manageiq import CompareToolBarActionsView
from widgetastic_manageiq import ItemsToolBarViewSelector
from widgetastic_manageiq import JSBaseEntity
from widgetastic_manageiq import ManageIQTree
from widgetastic_manageiq import Search
from widgetastic_manageiq import SummaryTable
from widgetastic_manageiq import Table


class DatastoreEntity(JSBaseEntity):
@property
def data(self):
data_dict = super().data
try:
if 'quadicon' in data_dict and data_dict['quadicon']:
quad_data = document_fromstring(data_dict['quadicon'])
data_dict['type'] = quad_data.xpath(self.QUADRANT.format(pos="a"))[0].get('alt')
data_dict['no_vm'] = quad_data.xpath(self.QUADRANT.format(pos="b"))[0].text
data_dict['no_host'] = quad_data.xpath(self.QUADRANT.format(pos="c"))[0].text
return data_dict
except IndexError:
return {}


class DatastoreEntities(BaseEntitiesView):
"""
represents central view where all QuadIcons, etc are displayed
"""
@property
def entity_class(self):
return DatastoreEntity


class DatastoreToolBar(View):
"""
represents datastore toolbar and its controls
"""
configuration = Dropdown(text='Configuration')
policy = Dropdown(text='Policy')
monitoring = Dropdown("Monitoring")
download = Dropdown(text='Download')
view_selector = View.nested(ItemsToolBarViewSelector)


class DatastoreSideBar(View):
"""
represents left side bar. it usually contains navigation, filters, etc
"""
@View.nested
class datastores(Accordion): # noqa
ACCORDION_NAME = "Datastores"
tree = ManageIQTree()

@View.nested
class clusters(Accordion): # noqa
ACCORDION_NAME = "Datastore Clusters"
tree = ManageIQTree()


class DatastoresView(BaseLoggedInPage):
"""
represents whole All Datastores page
"""
toolbar = View.nested(DatastoreToolBar)
sidebar = View.nested(DatastoreSideBar)
search = View.nested(Search)
including_entities = View.include(DatastoreEntities, use_parent=True)

@property
def is_displayed(self):
return (super(BaseLoggedInPage, self).is_displayed and
self.navigation.currently_selected == ['Compute', 'Infrastructure',
'Datastores'] and
self.entities.title.text == 'All Datastores')


class HostAllDatastoresView(DatastoresView):

@property
def is_displayed(self):
return (
self.logged_in_as_current_user and
self.navigation.currently_selected == ["Compute", "Infrastructure", "Hosts"] and
self.entities.title.text == "{} (All Datastores)".format(self.context["object"].name)
)


class ProviderAllDatastoresView(DatastoresView):
"""
This view is used in test_provider_relationships
"""

@property
def is_displayed(self):
msg = "{} (All Datastores)".format(self.context["object"].name)
return (
self.logged_in_as_current_user and
self.navigation.currently_selected == ["Compute", "Infrastructure", "Providers"] and
self.entities.title.text == msg
)


class DatastoreManagedVMsView(BaseLoggedInPage):
"""
This view represents All VMs and Templates page for datastores
"""
toolbar = View.nested(DatastoreToolBar)
including_entities = View.include(VMEntities, use_parent=True)

@property
def is_displayed(self):
return (
super(BaseLoggedInPage, self).is_displayed
and self.navigation.currently_selected == ["Compute", "Infrastructure", "Datastores"]
and self.entities.title.text == f'{self.context["object"].name} (All VMs and Instances)'
and self.context["object"].name in self.breadcrumb.active_location
)


class DatastoreDetailsView(BaseLoggedInPage):
"""
represents Datastore Details page
"""
title = Text('//div[@id="main-content"]//h1')
toolbar = View.nested(DatastoreToolBar)
sidebar = View.nested(DatastoreSideBar)

@View.nested
class entities(View): # noqa
"""
represents Details page when it is switched to Summary aka Tables view
"""
properties = SummaryTable(title="Properties")
registered_vms = SummaryTable(title="Information for Registered VMs")
relationships = SummaryTable(title="Relationships")
content = SummaryTable(title="Content")
smart_management = SummaryTable(title="Smart Management")

@property
def is_displayed(self):
return (super(BaseLoggedInPage, self).is_displayed and
self.navigation.currently_selected == ['Compute', 'Infrastructure',
'Datastores'] and
self.title.text == 'Datastore "{name}"'.format(name=self.context['object'].name))


class DatastoresCompareView(BaseLoggedInPage):
"""Compare VM / Template page."""
# TODO: This table doesn't read properly, fix it.
table = Table('//*[@id="compare-grid"]/table')
title = Text('//*[@id="main-content"]//h1')

@View.nested
class toolbar(View):
actions = View.nested(CompareToolBarActionsView)
download = Dropdown(text="Download")

@property
def is_displayed(self):
return (
self.logged_in_as_current_user
and self.title.text == "Compare VM or Template"
and self.navigation.currently_selected == ["Compute", "Infrastructure", "Datastores"]
)
8 changes: 8 additions & 0 deletions cfme/common/host_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from cfme.common import BaseLoggedInPage
from cfme.common import CompareView
from cfme.common import TimelinesView
from cfme.exceptions import displayed_not_implemented
from cfme.utils.log import logger
from cfme.utils.version import Version
from cfme.utils.version import VersionPicker
Expand Down Expand Up @@ -431,3 +432,10 @@ class HostVmmInfoView(HostsView):
def is_displayed(self):
active_loc = f"{self.context['object'].name} (VM Monitor Information)"
return self.breadcrumb.active_location == active_loc


class RegisteredHostsView(HostsView):
"""
represents Hosts related to some datastore
"""
is_displayed = displayed_not_implemented
13 changes: 13 additions & 0 deletions cfme/common/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from cfme.base.credential import TokenCredential
from cfme.common import CustomButtonEventsMixin
from cfme.common import Taggable
from cfme.common.datastore_views import ProviderAllDatastoresView
from cfme.exceptions import AddProviderError
from cfme.exceptions import HostStatsNotContains
from cfme.exceptions import ProviderHasNoKey
Expand All @@ -26,6 +27,7 @@
from cfme.utils import conf
from cfme.utils import ParamClassName
from cfme.utils.appliance import Navigatable
from cfme.utils.appliance.implementations.ui import CFMENavigateStep
from cfme.utils.appliance.implementations.ui import navigate_to
from cfme.utils.appliance.implementations.ui import navigator
from cfme.utils.log import logger
Expand Down Expand Up @@ -1374,3 +1376,14 @@ class DefaultEndpointForm(View):
change_password = Text(locator='.//a[normalize-space(.)="Change stored password"]')

validate = Button('Validate')


@navigator.register(BaseProvider, 'DatastoresOfProvider')
class DatastoresOfProvider(CFMENavigateStep):
VIEW = ProviderAllDatastoresView

def prerequisite(self):
return navigate_to(self.obj, 'Details')

def step(self, *args, **kwargs):
self.prerequisite_view.entities.summary('Relationships').click_at('Datastores')
Loading

0 comments on commit 672e37b

Please sign in to comment.