Source code for cfme.services.service_catalogs.ui

from navmazing import NavigateToAttribute, NavigateToSibling
from widgetastic_manageiq import Accordion, ManageIQTree
from widgetastic_patternfly import Button
from widgetastic.widget import Text, View

from cfme.base import Server
from cfme.base.login import BaseLoggedInPage
from cfme.services.requests import RequestsView
from cfme.services.service_catalogs import ServiceCatalogs, BaseOrderForm
from cfme.utils.appliance import MiqImplementationContext
from cfme.utils.appliance.implementations.ui import navigator, CFMENavigateStep, navigate_to, ViaUI
from cfme.utils.blockers import BZ


[docs]class ServicesCatalogsView(BaseLoggedInPage): title = Text("#explorer_title_text") @property def in_service_catalogs(self): return ( self.logged_in_as_current_user and self.navigation.currently_selected == ['Services', 'Catalogs']) @View.nested class service_catalogs(Accordion): # noqa ACCORDION_NAME = "Service Catalogs" tree = ManageIQTree() @property def is_displayed(self): return ( self.in_service_catalogs and self.title.text == 'All Services' and self.service_catalogs.is_opened and self.service_catalogs.tree.currently_selected == ["All Services"])
[docs]class OrderForm(ServicesCatalogsView, BaseOrderForm): pass
[docs]class ServiceCatalogsDefaultView(ServicesCatalogsView): title = Text("#explorer_title_text") @property def is_displayed(self): return ( self.in_explorer and self.title.text == 'All Services' and self.service_catalogs.is_opened)
[docs]class DetailsServiceCatalogView(ServicesCatalogsView): title = Text("#explorer_title_text") order_button = Button("Order") @property def is_displayed(self): return ( self.in_explorer and self.service_catalogs.is_opened and self.title.text == 'Service "{}"'.format(self.context['object'].name) )
[docs]class OrderServiceCatalogView(OrderForm): title = Text('#explorer_title_text') submit_button = Button('Submit') @property def is_displayed(self): return ( self.in_service_catalogs and self.service_catalogs.is_opened and 'Service "{}"'.format(self.context['object'].name) in self.title.text and self.submit_button.is_displayed )
@MiqImplementationContext.external_for(ServiceCatalogs.order, ViaUI)
[docs]def order(self): view = navigate_to(self, 'Order', wait_for_view=True) if self.stack_data: view.fill(self.stack_data) if self.dialog_values: view.fill(self.dialog_values) if self.ansible_dialog_values: view.fill(self.ansible_dialog_values) msg = "Order Request was Submitted" msg_type = "info" view.submit_button.click() view = self.create_view(RequestsView) view.flash.assert_no_error() if not BZ(1605102, forced_streams=['5.10']).blocks: view.flash.assert_message(msg, msg_type) return self.appliance.collections.requests.instantiate(self.name, partial_check=True)
@navigator.register(Server)
[docs]class ServiceCatalogsDefault(CFMENavigateStep): VIEW = ServiceCatalogsDefaultView prerequisite = NavigateToAttribute('appliance.server', 'LoggedIn')
[docs] def step(self): self.prerequisite_view.navigation.select('Services', 'Catalogs')
@navigator.register(ServiceCatalogs, 'All')
[docs]class ServiceCatalogsAll(CFMENavigateStep): VIEW = ServicesCatalogsView prerequisite = NavigateToAttribute('appliance.server', 'LoggedIn')
[docs] def step(self): self.prerequisite_view.navigation.select('Services', 'Catalogs') self.view.service_catalogs.tree.click_path("All Services")
@navigator.register(ServiceCatalogs, 'Details')
[docs]class ServiceCatalogDetails(CFMENavigateStep): VIEW = DetailsServiceCatalogView prerequisite = NavigateToSibling('All')
[docs] def step(self): self.prerequisite_view.service_catalogs.tree.click_path( "All Services", self.obj.catalog.name, self.obj.name )
@navigator.register(ServiceCatalogs, 'Order')
[docs]class ServiceCatalogOrder(CFMENavigateStep): VIEW = OrderServiceCatalogView prerequisite = NavigateToSibling('Details')
[docs] def step(self): self.prerequisite_view.order_button.click()