# -*- coding: utf-8 -*-
from widgetastic.widget import View, Text, TextInput, Select
from widgetastic_patternfly import (Dropdown,
FlashMessages,
BootstrapSwitch,
BootstrapNav,
Tab)
from cfme.base.login import BaseLoggedInPage
from widgetastic_manageiq import (Accordion,
BreadCrumb,
SummaryTable,
Button,
TimelinesView,
ItemsToolBarViewSelector,
Table,
BaseEntitiesView,
FileInput,
Search)
LIST_TABLE_LOCATOR = '//div[@id="list_grid" or contains(@class, "miq-data-table")]//table'
TITLE_LOCATOR = '//div[@id="main-content"]//h1'
FLASH_MESSAGE_LOCATOR = './/div[@id="flash_msg_div"]'\
'/div[@id="flash_text_div" or contains(@class, "flash_text_div")]'
TITLE_LOCATOR = '//div[@id="main-content"]//h1'
[docs]class JDREntitiesView(View):
"""Entities on the JDR Reports list"""
title = Text('//div[@id="mw_dr_header"]//h3')
table = Table('//div[@id="mw_dr_section"]//table')
# element attributes changed from id to class in upstream-fine+, capture both with locator
flash = FlashMessages(FLASH_MESSAGE_LOCATOR)
[docs]class JDRAllView(View):
"""The "all" view -- a list of JDR Reports"""
toolbar = View.nested(JDRToolbar)
including_entities = View.include(JDREntitiesView, use_parent=True)
[docs]class ServerDetailsAccordion(View):
"""The accordian on the details page"""
@View.nested
class server(Accordion): # noqa
pass
@View.nested
class properties(Accordion): # noqa
nav = BootstrapNav('//div[@id="middleware_server_prop"]//ul')
@View.nested
class relationships(Accordion): # noqa
nav = BootstrapNav('//div[@id="middleware_server_rel"]//ul')
[docs]class ServerEntitiesView(BaseEntitiesView):
"""Entities on the main list page"""
title = Text(TITLE_LOCATOR)
table = Table(LIST_TABLE_LOCATOR)
search = View.nested(Search)
# element attributes changed from id to class in upstream-fine+, capture both with locator
flash = FlashMessages(FLASH_MESSAGE_LOCATOR)
[docs]class ServerDetailsEntities(View):
"""Entities on the details page"""
breadcrumb = BreadCrumb()
title = Text(TITLE_LOCATOR)
properties = SummaryTable(title='Properties')
relationships = SummaryTable(title='Relationships')
smart_management = SummaryTable(title='Smart Management')
flash = FlashMessages(FLASH_MESSAGE_LOCATOR)
[docs]class ServerView(BaseLoggedInPage):
"""Base view for header and nav checking, navigatable views should inherit this"""
@property
def in_server(self):
nav_chain = ['Middleware', 'Servers']
return (
self.logged_in_as_current_user and
self.navigation.currently_selected == nav_chain)
[docs]class ServerAllView(ServerView):
"""The "all" view -- a list of servers"""
@property
def is_displayed(self):
return (
self.in_server and
self.entities.title.text == 'Middleware Servers')
toolbar = View.nested(ServerToolbar)
including_entities = View.include(ServerEntitiesView, use_parent=True)
[docs]class ProviderServerAllView(ServerView):
"""The "all" view -- a list of provider's servers"""
@property
def is_displayed(self):
expected_title = '{} (All Middleware Servers)'.format(self.context['object'].name)
return (
self.in_server and
self.entities.title.text == expected_title and
self.entities.breadcrumb.active_location == expected_title)
toolbar = View.nested(ServerToolbar)
including_entities = View.include(ServerEntitiesView, use_parent=True)
[docs]class ServerGroupServerAllView(ServerView):
"""The "all" view -- a list of server group servers"""
@property
def is_displayed(self):
nav_chain = ['Middleware', 'Domains']
expected_title = '{name} (All Middleware Servers)'.format(name=self.context['object'].name)
return (
self.logged_in_as_current_user and
self.navigation.currently_selected == nav_chain and
self.title.text == expected_title)
toolbar = View.nested(ServerToolbar)
including_entities = View.include(ServerEntitiesView, use_parent=True)
[docs]class ServerDetailsView(ServerView):
"""The details page of a datasource"""
@property
def is_displayed(self):
"""Is this page being displayed?"""
expected_title = '{} (Summary)'.format(self.context['object'].name)
return (
self.in_server and
self.entities.title.text == expected_title and
self.entities.breadcrumb.active_location == expected_title)
toolbar = View.nested(ServerDetailsToolbar)
sidebar = View.nested(ServerDetailsAccordion)
entities = View.nested(ServerDetailsEntities)
power_operation_form = View.nested(PowerOperationForm)
flash = FlashMessages(FLASH_MESSAGE_LOCATOR)
jdr_reports = View.nested(JDRAllView)
[docs]class DatasourceDetailsAccordion(View):
"""The accordian on the details page"""
@View.nested
class datasource(Accordion): # noqa
pass
@View.nested
class properties(Accordion): # noqa
nav = BootstrapNav('//div[@id="middleware_datasource_prop"]//ul')
@View.nested
class relationships(Accordion): # noqa
nav = BootstrapNav('//div[@id="middleware_datasource_rel"]//ul')
[docs]class DatasourceEntitiesView(BaseEntitiesView):
"""Entities on the main list page"""
title = Text(TITLE_LOCATOR)
table = Table(LIST_TABLE_LOCATOR)
search = View.nested(Search)
# element attributes changed from id to class in upstream-fine+, capture both with locator
flash = FlashMessages(FLASH_MESSAGE_LOCATOR)
[docs]class DatasourceDetailsEntities(View):
"""Entities on the details page"""
breadcrumb = BreadCrumb()
title = Text(TITLE_LOCATOR)
properties = SummaryTable(title='Properties')
relationships = SummaryTable(title='Relationships')
smart_management = SummaryTable(title='Smart Management')
flash = FlashMessages(FLASH_MESSAGE_LOCATOR)
[docs]class DatasourceView(BaseLoggedInPage):
"""Base view for header and nav checking, navigatable views should inherit this"""
@property
def in_datasource(self):
nav_chain = ['Middleware', 'Datasources']
return (
self.logged_in_as_current_user and
self.navigation.currently_selected == nav_chain)
[docs]class DatasourceAllView(DatasourceView):
"""The "all" view -- a list of datasources"""
@property
def is_displayed(self):
return (
self.in_datasource and
self.entities.title.text == 'Middleware Datasources')
toolbar = View.nested(DatasourceAllToolbar)
including_entities = View.include(DatasourceEntitiesView, use_parent=True)
[docs]class DatasourceDetailsView(DatasourceView):
"""The details page of a datasource"""
@property
def is_displayed(self):
"""Is this page being displayed?"""
expected_title = '{} (Summary)'.format(self.context['object'].name)
return (
self.in_datasource and
self.entities.title.text == expected_title and
self.entities.breadcrumb.active_location == expected_title)
toolbar = View.nested(DatasourceDetailsToolbar)
sidebar = View.nested(DatasourceDetailsAccordion)
entities = View.nested(DatasourceDetailsEntities)
flash = FlashMessages(FLASH_MESSAGE_LOCATOR)
[docs]class ServerDatasourceAllView(DatasourceView):
"""The "all" view -- a list of server's datasources"""
@property
def is_displayed(self):
expected_title = '{} (All Middleware Datasources)'.format(self.context['object'].name)
return (
self.in_datasource and
self.entities.title.text == expected_title and
self.entities.breadcrumb.active_location == expected_title)
toolbar = View.nested(DatasourceAllToolbar)
including_entities = View.include(DatasourceEntitiesView, use_parent=True)
[docs]class ProviderDatasourceAllView(DatasourceView):
"""The "all" view -- a list of provider's datasources"""
@property
def is_displayed(self):
expected_title = '{} (All Middleware Datasources)'.format(self.context['object'].name)
return (
self.in_datasource and
self.entities.title.text == expected_title and
self.entities.breadcrumb.active_location == expected_title)
toolbar = View.nested(DatasourceAllToolbar)
including_entities = View.include(DatasourceEntitiesView, use_parent=True)
[docs]class AddDatasourceView(DatasourceView):
"""The "Add" view -- new datasources"""
@property
def is_displayed(self):
""" This view is opened as a widget box after clicking on toolbar operation """
return False
form = View.nested(AddDatasourceForm)
flash = FlashMessages(FLASH_MESSAGE_LOCATOR)
[docs]class AddJDBCDriverView(View):
"""The "Add" view -- new JDBC Drivers"""
@property
def is_displayed(self):
""" This view is opened as a widget box after clicking on toolbar operation """
return False
form = View.nested(AddJDBCDriverForm)
flash = FlashMessages(FLASH_MESSAGE_LOCATOR)
[docs]class DeploymentDetailsAccordion(View):
"""The accordian on the details page"""
@View.nested
class deployment(Accordion): # noqa
pass
@View.nested
class properties(Accordion): # noqa
nav = BootstrapNav('//div[@id="middleware_deployment_prop"]//ul')
@View.nested
class relationships(Accordion): # noqa
nav = BootstrapNav('//div[@id="middleware_deployment_rel"]//ul')
[docs]class DeploymentEntitiesView(BaseEntitiesView):
"""Entities on the main list page"""
title = Text(TITLE_LOCATOR)
table = Table(LIST_TABLE_LOCATOR)
search = View.nested(Search)
# element attributes changed from id to class in upstream-fine+, capture both with locator
flash = FlashMessages(FLASH_MESSAGE_LOCATOR)
[docs]class DeploymentDetailsEntities(View):
"""Entities on the details page"""
breadcrumb = BreadCrumb()
title = Text(TITLE_LOCATOR)
properties = SummaryTable(title='Properties')
relationships = SummaryTable(title='Relationships')
smart_management = SummaryTable(title='Smart Management')
flash = FlashMessages(FLASH_MESSAGE_LOCATOR)
[docs]class DeploymentView(BaseLoggedInPage):
"""Base view for header and nav checking, navigatable views should inherit this"""
@property
def in_deployment(self):
nav_chain = ['Middleware', 'Deployments']
return (
self.logged_in_as_current_user and
self.navigation.currently_selected == nav_chain)
[docs]class DeploymentAllView(DeploymentView):
"""The "all" view -- a list of deployments"""
@property
def is_displayed(self):
return (
self.in_deployment and
self.entities.title.text == 'Middleware Deployments')
toolbar = View.nested(DatasourceAllToolbar)
including_entities = View.include(DeploymentEntitiesView, use_parent=True)
[docs]class DeploymentDetailsView(DeploymentView):
"""The details page of a deployment"""
@property
def is_displayed(self):
"""Is this page being displayed?"""
expected_title = '{} (Summary)'.format(self.context['object'].name)
return (
self.in_deployment and
self.entities.title.text == expected_title and
self.entities.breadcrumb.active_location == expected_title)
toolbar = View.nested(DeploymentDetailsToolbar)
sidebar = View.nested(DeploymentDetailsAccordion)
entities = View.nested(DeploymentDetailsEntities)
flash = FlashMessages(FLASH_MESSAGE_LOCATOR)
[docs]class ServerDeploymentAllView(DeploymentView):
"""The "all" view -- a list of server's deployments"""
@property
def is_displayed(self):
expected_title = '{} (All Middleware Deployments)'.format(self.context['object'].name)
return (
self.in_deployment and
self.entities.title.text == expected_title and
self.entities.breadcrumb.active_location == expected_title)
toolbar = View.nested(DeploymentAllToolbar)
including_entities = View.include(DeploymentEntitiesView, use_parent=True)
[docs]class ProviderDeploymentAllView(DeploymentView):
"""The "all" view -- a list of provider's deployments"""
@property
def is_displayed(self):
expected_title = '{} (All Middleware Deployments)'.format(self.context['object'].name)
return (
self.in_deployment and
self.entities.title.text == expected_title and
self.entities.breadcrumb.active_location == expected_title)
toolbar = View.nested(DeploymentAllToolbar)
including_entities = View.include(DeploymentEntitiesView, use_parent=True)
[docs]class AddDeploymentView(DeploymentView):
"""The "Add" view -- new deployments"""
@property
def is_displayed(self):
""" This view is opened as a widget box after clicking on toolbar operation """
return False
form = View.nested(AddDeploymentForm)
flash = FlashMessages(FLASH_MESSAGE_LOCATOR)
[docs]class DomainToolbar(View):
"""The toolbar on the main page"""
policy = Dropdown('Policy')
download = Dropdown('Download')
view_selector = View.nested(ItemsToolBarViewSelector)
[docs]class DomainDetailsToolbar(View):
"""The toolbar on the details page"""
policy = Dropdown('Policy')
power = Dropdown('Power')
download = Button(title='Download summary in PDF format')
[docs]class DomainDetailsAccordion(View):
"""The accordian on the details page"""
@View.nested
class domain(Accordion): # noqa
pass
@View.nested
class properties(Accordion): # noqa
nav = BootstrapNav('//div[@id="middleware_domain_prop"]//ul')
@View.nested
class relationships(Accordion): # noqa
nav = BootstrapNav('//div[@id="middleware_domain_rel"]//ul')
[docs]class DomainEntitiesView(BaseEntitiesView):
"""Entities on the main list page"""
title = Text(TITLE_LOCATOR)
table = Table(LIST_TABLE_LOCATOR)
search = View.nested(Search)
# element attributes changed from id to class in upstream-fine+, capture both with locator
flash = FlashMessages(FLASH_MESSAGE_LOCATOR)
[docs]class DomainDetailsEntities(View):
"""Entities on the details page"""
breadcrumb = BreadCrumb()
title = Text(TITLE_LOCATOR)
properties = SummaryTable(title='Properties')
relationships = SummaryTable(title='Relationships')
smart_management = SummaryTable(title='Smart Management')
flash = FlashMessages(FLASH_MESSAGE_LOCATOR)
[docs]class DomainView(BaseLoggedInPage):
"""Base view for header and nav checking, navigatable views should inherit this"""
@property
def in_domain(self):
nav_chain = ['Middleware', 'Domains']
return (
self.logged_in_as_current_user and
self.navigation.currently_selected == nav_chain)
[docs]class DomainAllView(DomainView):
"""The "all" view -- a list of domains"""
@property
def is_displayed(self):
return (
self.in_domain and
self.entities.title.text == 'Middleware Domains')
toolbar = View.nested(DomainToolbar)
including_entities = View.include(DomainEntitiesView, use_parent=True)
[docs]class ProviderDomainsAllView(DomainView):
"""The "all" view -- a list of provider's domains"""
@property
def is_displayed(self):
expected_title = '{} (All Middleware Domains)'.format(self.context['object'].name)
return (
self.in_domain and
self.entities.title.text == expected_title and
self.entities.breadcrumb.active_location == expected_title)
toolbar = View.nested(DomainToolbar)
including_entities = View.include(DomainEntitiesView, use_parent=True)
[docs]class DomainDetailsView(DomainView):
"""The details page of a domain"""
@property
def is_displayed(self):
"""Is this page being displayed?"""
expected_title = '{} (Summary)'.format(self.context['object'].name)
return (
self.in_domain and
self.entities.title.text == expected_title and
self.entities.breadcrumb.active_location == expected_title)
toolbar = View.nested(DomainDetailsToolbar)
sidebar = View.nested(DomainDetailsAccordion)
entities = View.nested(DomainDetailsEntities)
[docs]class ProviderDomainAllView(DomainView):
"""The "all" view -- a list of provider's domains"""
@property
def is_displayed(self):
expected_title = '{} (All Middleware Domains)'.format(self.context['object'].name)
return (
self.in_domain and
self.entities.title.text == expected_title and
self.entities.breadcrumb.active_location == expected_title)
toolbar = View.nested(DomainToolbar)
including_entities = View.include(DomainEntitiesView, use_parent=True)
[docs]class MessagingDetailsAccordion(View):
"""The accordian on the details page"""
@View.nested
class messaging(Accordion): # noqa
pass
@View.nested
class properties(Accordion): # noqa
nav = BootstrapNav('//div[@id="middleware_messaging_prop"]//ul')
@View.nested
class relationships(Accordion): # noqa
nav = BootstrapNav('//div[@id="middleware_messaging_rel"]//ul')
[docs]class MessagingEntitiesView(BaseEntitiesView):
"""Entities on the main list page"""
title = Text(TITLE_LOCATOR)
table = Table(LIST_TABLE_LOCATOR)
search = View.nested(Search)
# element attributes changed from id to class in upstream-fine+, capture both with locator
flash = FlashMessages(FLASH_MESSAGE_LOCATOR)
[docs]class MessagingDetailsEntities(View):
"""Entities on the details page"""
breadcrumb = BreadCrumb()
title = Text(TITLE_LOCATOR)
properties = SummaryTable(title='Properties')
relationships = SummaryTable(title='Relationships')
smart_management = SummaryTable(title='Smart Management')
flash = FlashMessages(FLASH_MESSAGE_LOCATOR)
[docs]class MessagingView(BaseLoggedInPage):
"""Base view for header and nav checking, navigatable views should inherit this"""
@property
def in_messaging(self):
nav_chain = ['Middleware', 'Messagings']
return (
self.logged_in_as_current_user and
self.navigation.currently_selected == nav_chain)
[docs]class MessagingAllView(MessagingView):
"""The "all" view -- a list of deployments"""
@property
def is_displayed(self):
return (
self.in_messaging and
self.entities.title.text == 'Middleware Messagings')
toolbar = View.nested(MessagingAllToolbar)
including_entities = View.include(MessagingEntitiesView, use_parent=True)
[docs]class MessagingDetailsView(MessagingView):
"""The details page of a deployment"""
@property
def is_displayed(self):
"""Is this page being displayed?"""
expected_title = '{} (Summary)'.format(self.context['object'].name)
return (
self.in_messaging and
self.entities.title.text == expected_title and
self.entities.breadcrumb.active_location == expected_title)
toolbar = View.nested(MessagingDetailsToolbar)
sidebar = View.nested(MessagingDetailsAccordion)
entities = View.nested(MessagingDetailsEntities)
[docs]class ServerMessagingAllView(MessagingView):
"""The "all" view -- a list of server's messagings"""
@property
def is_displayed(self):
expected_title = '{} (All Middleware Messagings)'.format(self.context['object'].name)
return (
self.in_messaging and
self.entities.title.text == expected_title and
self.entities.breadcrumb.active_location == expected_title)
toolbar = View.nested(MessagingAllToolbar)
including_entities = View.include(MessagingEntitiesView, use_parent=True)
[docs]class ProviderMessagingAllView(MessagingView):
"""The "all" view -- a list of provider's messagings"""
@property
def is_displayed(self):
expected_title = '{} (All Middleware Messagings)'.format(self.context['object'].name)
return (
self.in_messaging and
self.entities.title.text == expected_title and
self.entities.breadcrumb.active_location == expected_title)
toolbar = View.nested(MessagingAllToolbar)
including_entities = View.include(MessagingEntitiesView, use_parent=True)
[docs]class ServerGroupDetailsAccordion(View):
"""The accordian on the details page"""
@View.nested
class server_group(Accordion): # noqa
pass
@View.nested
class properties(Accordion): # noqa
nav = BootstrapNav('//div[@id="middleware_server_prop"]//ul')
@View.nested
class relationships(Accordion): # noqa
nav = BootstrapNav('//div[@id="middleware_server_rel"]//ul')
[docs]class ServerGroupEntitiesView(BaseEntitiesView):
"""Entities on the main list page"""
title = Text(TITLE_LOCATOR)
table = Table(LIST_TABLE_LOCATOR)
search = View.nested(Search)
# element attributes changed from id to class in upstream-fine+, capture both with locator
flash = FlashMessages(FLASH_MESSAGE_LOCATOR)
[docs]class ServerGroupDetailsEntities(View):
"""Entities on the details page"""
breadcrumb = BreadCrumb()
title = Text(TITLE_LOCATOR)
properties = SummaryTable(title='Properties')
relationships = SummaryTable(title='Relationships')
smart_management = SummaryTable(title='Smart Management')
flash = FlashMessages(FLASH_MESSAGE_LOCATOR)
[docs]class ServerGroupView(BaseLoggedInPage):
"""Base view for header and nav checking, navigatable views should inherit this"""
[docs]class ServerGroupDetailsView(ServerGroupView):
"""The details page of a server group"""
@property
def is_displayed(self):
"""Is this page being displayed?"""
expected_title = '{} (Summary)'.format(self.context['object'].name)
return (
self.entities.title.text == expected_title and
self.entities.breadcrumb.active_location == expected_title)
toolbar = View.nested(ServerGroupDetailsToolbar)
sidebar = View.nested(ServerGroupDetailsAccordion)
entities = View.nested(ServerGroupDetailsEntities)
power_operation_form = View.nested(PowerOperationForm)
flash = FlashMessages(FLASH_MESSAGE_LOCATOR)
[docs]class DomainServerGroupAllView(DomainView):
"""The "all" view -- a list of domain's server groups"""
@property
def is_displayed(self):
expected_title = '{} (All Middleware Server Groups)' \
.format(self.context['object'].domain.name)
return (
self.in_server_group and
self.entities.title.text == expected_title and
self.entities.breadcrumb.active_location == expected_title)
toolbar = View.nested(ServerGroupToolbar)
including_entities = View.include(ServerGroupEntitiesView, use_parent=True)
[docs]class MiddlewareProviderTimelinesView(TimelinesView, BaseLoggedInPage):
@property
def is_displayed(self):
return (
self.logged_in_as_current_user and
self.navigation.currently_selected == ['Middleware', 'Providers'] and
'{} (Summary)'.format(self.context['object'].name) in self.breadcrumb.locations and
self.is_timelines)