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 #5616 from sshveta/ssui_set_ownership
Browse files Browse the repository at this point in the history
SSUI set ownership
  • Loading branch information
psav authored Oct 20, 2017
2 parents a9ac1dd + 0e80c3c commit 7899b3e
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 9 deletions.
138 changes: 133 additions & 5 deletions cfme/services/myservice/ssui.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from navmazing import NavigateToAttribute, NavigateToSibling
from widgetastic.widget import Text
from widgetastic_manageiq import SSUIlist, SSUIDropdown, SSUIAppendToBodyDropdown
from widgetastic.widget import Text, Select
from widgetastic_manageiq import SSUIlist, SSUIDropdown, Notification, SSUIAppendToBodyDropdown
from widgetastic_patternfly import Input, Button

from cfme.base.ssui import SSUIBaseLoggedInPage
Expand All @@ -12,13 +12,15 @@
ViaSSUI
)
from cfme.utils.wait import wait_for

from . import MyService
# TO DO - remove sleep when BZ 1496233 is fixed
import time


class MyServicesView(SSUIBaseLoggedInPage):
title = Text(locator='//li[@class="active"]')
service = SSUIlist(list_name='serviceList')
notification = Notification()

def in_myservices(self):
return (
Expand All @@ -38,6 +40,7 @@ def is_displayed(self):
return (self.in_myservices and
self.title.text in {self.context['object'].name, 'Service Details'})

notification = Notification()
configuration = SSUIDropdown('Configuration')
policy_btn = SSUIDropdown('Policy')
lifecycle_btn = SSUIDropdown('Lifecycle')
Expand All @@ -52,6 +55,14 @@ class ServiceEditForm(MyServicesView):
description = Input(name='description')


class SetOwnershipForm(MyServicesView):

select_owner = Select(
locator='.//select[../../../label[normalize-space(text())="Select an Owner"]]')
select_group = Select(
locator='.//select[../../../label[normalize-space(text())="Select a Group"]]')


class EditMyServiceView(ServiceEditForm):
title = Text(locator='//li[@class="active"]')

Expand All @@ -67,6 +78,51 @@ def is_displayed(self):
)


class SetOwnershipView(SetOwnershipForm):
title = Text(locator='//h4[@id="myModalLabel"]')

save_button = Button('Save')

@property
def is_displayed(self):
return (
self.in_myservices and
self.title.text == 'Set Service Ownership')


class TagForm(MyServicesView):

tag_category = Select(locator='.//select[contains(@class, "tag-category-select")]')
tag_name = Select(locator='.//select[contains(@class, "tag-value-select")]')
add_tag = Text(locator='.//a/span[contains(@class, "tag-add")]')
save = Button('Save')
reset = Button('Reset')
cancel = Button('Cancel')


class TagPageView(TagForm):
title = Text(locator='//h4[@id="myModalLabel"]')

@property
def is_displayed(self):
return (
self.in_myservices and
self.title.text == 'Edit Tags')


class RemoveServiceView(MyServicesView):
title = Text(locator='//h4[@id="myModalLabel"]')

remove = Button('Yes, Remove Service')
cancel = Button('Cancel')

@property
def is_displayed(self):
return (
self.in_myservices and
self.title.text == 'Remove Service')


@MyService.update.external_implementation_for(ViaSSUI)
def update(self, updates):
view = navigate_to(self, 'Edit')
Expand All @@ -77,7 +133,62 @@ def update(self, updates):
lambda: view.is_displayed, delay=15, num_sec=300,
message="waiting for view to be displayed"
)
# TODO - implement notifications and then assert.
# TODO - remove sleep when BZ 1496233 is fixed
time.sleep(10)
assert view.notification.assert_message(
"{} was edited.".format(self.name))


@MyService.set_ownership.external_implementation_for(ViaSSUI)
def set_ownership(self, owner, group):
view = navigate_to(self, 'SetOwnership')
wait_for(
lambda: view.select_owner.is_displayed, delay=5, num_sec=300,
message="waiting for view to be displayed"
)
view.fill({'select_owner': owner,
'select_group': group})
view.save_button.click()
view = self.create_view(DetailsMyServiceView)
assert view.is_displayed
# TODO - remove sleep when BZ 1496233 is fixed
time.sleep(10)
assert view.notification.assert_message("Setting ownership.")


@MyService.edit_tags.external_implementation_for(ViaSSUI)
def edit_tags(self, tag, value):
view = navigate_to(self, 'EditTagsFromDetails')
wait_for(
lambda: view.tag_category.is_displayed, delay=15, num_sec=300,
message="waiting for view to be displayed"
)
view.fill({'tag_category': tag,
'tag_name': value})
view.add_tag.click()
view.save.click()
view = self.create_view(DetailsMyServiceView)
assert view.is_displayed
# TODO - remove sleep when BZ 1496233 is fixed
time.sleep(10)
assert view.notification.assert_message("Tagging successful.")


@MyService.delete.external_implementation_for(ViaSSUI)
def delete(self):
view = navigate_to(self, 'Details')
view.configuration.item_select('Remove')
view = self.create_view(RemoveServiceView)
view.remove.click()
view = self.create_view(MyServicesView)
wait_for(
lambda: view.is_displayed, delay=15, num_sec=300,
message="waiting for view to be displayed"
)
assert view.is_displayed
# TODO - remove sleep when BZ 1496233 is fixed
time.sleep(10)
assert view.notification.assert_message("{} was removed.".format(self.name))


@MyService.launch_vm_console.external_implementation_for(ViaSSUI)
Expand Down Expand Up @@ -126,8 +237,25 @@ def step(self):
@navigator.register(MyService, 'VM Console')
class LaunchVMConsole(SSUINavigateStep):
VIEW = EditMyServiceView

prerequisite = NavigateToSibling('Details')

def step(self):
self.prerequisite_view.access_dropdown.item_select('VM Console')


@navigator.register(MyService, 'SetOwnership')
class MyServiceSetOwnership(SSUINavigateStep):
VIEW = SetOwnershipView
prerequisite = NavigateToSibling('Details')

def step(self):
self.prerequisite_view.configuration.item_select('Set Ownership')


@navigator.register(MyService, 'EditTagsFromDetails')
class MyServiceEditTags(SSUINavigateStep):
VIEW = TagPageView
prerequisite = NavigateToSibling('Details')

def step(self):
self.prerequisite_view.policy_btn.item_select('Edit Tags')
8 changes: 5 additions & 3 deletions cfme/tests/ssui/test_ssui_myservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ def test_myservice_crud(appliance, setup_provider, context, order_catalog_item_i
service_name = order_catalog_item_in_ops_ui.name
with appliance.context.use(context):
appliance.server.login()
myservice = MyService(appliance, service_name)
myservice.update({'name': '{}_edited'.format(service_name)})
# TODO - add rest of myservice crud like delete in next phase.
my_service = MyService(appliance, service_name)
my_service.set_ownership("Administrator", "EvmGroup-administrator")
my_service.update({'description': '{}_edited'.format(service_name)})
my_service.edit_tags("Cost Center", "Cost Center 001")
my_service.delete()


@pytest.mark.uncollectif(lambda: current_version() < '5.8')
Expand Down
6 changes: 5 additions & 1 deletion widgetastic_manageiq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,8 @@ class notification_drawer(ParametrizedView): # noqa
notification_bell = Text('.//li/a[contains(@title, "notifications")]/i')
events = Text(".//h4[contains(@class, 'panel-title')]")
find_event = Text(ParametrizedLocator('.//div[contains(@class, "drawer-pf-notification")]'
'/div/span[normalize-space(.)={message|quote}]'))
'/div/span'
'[contains(normalize-space(.), {message|quote})]'))

def click_bell(self):
"""Opens and closes the notification bell at the Nav bar"""
Expand All @@ -1346,6 +1347,9 @@ def event_click(self):
self.click_bell()
self.events.click()
self.find_event.click()
# close events and bell
self.events.click()
self.click_bell()

def __init__(self, parent, logger=None):
Widget.__init__(self, parent, logger=logger)
Expand Down

0 comments on commit 7899b3e

Please sign in to comment.