import time
from navmazing import NavigateToAttribute, NavigateToSibling
from widgetastic.widget import Text
from widgetastic_patternfly import Input, Button, BootstrapSelect
from cfme.base.ssui import SSUIBaseLoggedInPage
from cfme.services.service_catalogs import ServiceCatalogs, BaseOrderForm
from cfme.utils.appliance import MiqImplementationContext
from cfme.utils.appliance.implementations.ssui import (
navigator,
SSUINavigateStep,
navigate_to,
ViaSSUI
)
from cfme.utils.wait import wait_for
from widgetastic_manageiq import SSUIServiceCatalogcard, Notification
[docs]class ServiceCatalogsView(SSUIBaseLoggedInPage):
title = Text(locator='//li[@class="active"]')
service = SSUIServiceCatalogcard()
@property
def in_service_catalogs(self):
return (
self.logged_in_as_current_user and
self.navigation.currently_selected == ["", "Service Catalog"])
@property
def is_displayed(self):
return self.in_service_catalogs and self.title.text == "Service Catalog"
[docs]class DetailsServiceCatalogsView(OrderForm):
title = Text(locator='//li[@class="active"]')
notification = Notification()
add_to_shopping_cart = Button('Add to Shopping Cart')
shopping_cart = Text('.//li/a[@title="Shopping cart"]')
@property
def is_displayed(self):
return (
self.in_service_catalogs and
self.title.text == self.context['object'].name)
@MiqImplementationContext.external_for(ServiceCatalogs.add_to_shopping_cart, ViaSSUI)
@MiqImplementationContext.external_for(ServiceCatalogs.order, ViaSSUI)
[docs]def order(self):
view = navigate_to(self, 'ShoppingCart')
wait_for(
lambda: view.is_displayed, delay=5, num_sec=300,
message="waiting for view to be displayed"
)
view.order.click()
# TODO - remove sleep when BZ 1496233 is fixed
time.sleep(10)
assert view.notification.assert_message("Shopping cart successfully ordered")
@navigator.register(ServiceCatalogs, 'All')
[docs]class ServiceCatalogAll(SSUINavigateStep):
VIEW = ServiceCatalogsView
prerequisite = NavigateToAttribute('appliance.server', 'LoggedIn')
[docs] def step(self, *args, **kwargs):
self.prerequisite_view.navigation.select('Service Catalog')
@navigator.register(ServiceCatalogs, 'Details')
[docs]class Details(SSUINavigateStep):
VIEW = DetailsServiceCatalogsView
prerequisite = NavigateToSibling('All')
[docs] def step(self, *args, **kwargs):
self.prerequisite_view.service.click_at(self.obj.name)
@navigator.register(ServiceCatalogs, 'ShoppingCart')