Source code for cfme.services.service_catalogs.ssui
from navmazing import NavigateToAttribute, NavigateToSibling
from widgetastic.widget import Text
from widgetastic_manageiq import SSUIServiceCatalogcard, SSUIInput, Notification
from widgetastic_patternfly import Input, Button, BootstrapSelect
from cfme.base.ssui import SSUIBaseLoggedInPage
from cfme.services.service_catalogs import ServiceCatalogs
from cfme.utils.appliance.implementations.ssui import (
navigator,
SSUINavigateStep,
navigate_to,
ViaSSUI
)
from cfme.utils.wait import wait_for
import time
[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 OrderForm(ServiceCatalogsView):
title = Text('#explorer_title_text')
service_name = SSUIInput()
timeout = Input(name='stack_timeout')
db_user = Input(name="param_DBUser__protected")
db_root_password = Input(name='param_DBRootPassword__protected')
select_instance_type = BootstrapSelect("param_InstanceType")
stack_name = Input(name='stack_name')
stack_timeout = Input(name='stack_timeout')
resource_group = BootstrapSelect("resource_group")
mode = BootstrapSelect('deploy_mode')
vm_name = Input(name="param_virtualMachineName")
vm_user = Input(name='param_adminUserName')
vm_password = Input(name="param_adminPassword__protected")
vm_size = BootstrapSelect('param_virtualMachineSize')
user_image = BootstrapSelect("param_userImageName")
os_type = BootstrapSelect('param_operatingSystemType')
key_name = Input(name="param_KeyName")
ssh_location = Input(name="param_SSHLocation")
flavor = Input(name='param_flavor')
image = Input(name="param_image")
key = Input(name='param_key')
private_network = Input(name="param_private_network")
default_select_value = BootstrapSelect('service_level')
machine_credential = BootstrapSelect("credential")
hosts = Input(name="hosts")
[docs]class DetailsServiceCatalogsView(OrderForm):
title = Text(locator='//li[@class="active"]')
notification = Notification()
add_to_shopping_cart = Button('Add to Shopping Cart')
@property
def is_displayed(self):
return (
self.in_service_catalogs and
self.title.text == self.context['object'].name)
[docs]class DuplicateShoppingCartItemView(OrderForm):
title = Text(locator='//h4[@id="myModalLabel"]')
cancel_button = Button('Cancel')
add_to_shopping_cart = Button('Add to Shopping Cart')
@property
def is_displayed(self):
return (
self.in_service_catalogs and
self.title.text == "Duplicate Shopping Cart Item"
)
@ServiceCatalogs.add_to_shopping_cart.external_implementation_for(ViaSSUI)
[docs]def add_to_shopping_cart(self):
view = navigate_to(self, 'Details')
wait_for(
lambda: view.is_displayed, delay=5, num_sec=300,
message="waiting for view to be displayed"
)
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)
view.add_to_shopping_cart.click()
view.flash.assert_no_error()
duplicateview = self.create_view(DuplicateShoppingCartItemView)
if duplicateview.is_displayed:
duplicateview.add_to_shopping_cart.click()
view = self.create_view(DetailsServiceCatalogsView)
# There is a pop up that stays for 10 secs and blocks opening up the drawer
# Only way to remove is to wait for 10 secs.
# TODO - remove sleep when BZ 1496233 is fixed
time.sleep(10)
assert view.notification.assert_message("Item added to shopping cart")
@navigator.register(ServiceCatalogs, 'All')
[docs]class ServiceCatalogAll(SSUINavigateStep):
VIEW = ServiceCatalogsView
prerequisite = NavigateToAttribute('appliance.server', 'LoggedIn')
@navigator.register(ServiceCatalogs, 'Details')