Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

[WIP] Views for new Red Hat Cloud pages #9184

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions cfme/base/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from cfme.base import ZoneCollection
from cfme.base.credential import Credential
from cfme.base.login import BaseLoggedInPage
from cfme.cloud_insights.services import CloudInsightsServicesView
from cfme.configure.about import AboutView
from cfme.configure.configuration.server_settings import ServerAuthenticationView
from cfme.configure.configuration.server_settings import ServerInformationView
Expand Down Expand Up @@ -1741,3 +1742,13 @@ class AutomateSimulation(CFMENavigateStep):

def step(self, *args, **kwargs):
self.prerequisite_view.navigation.select(*["Automation", "Automate", "Simulation"])


# Red Hat Cloud - Insights
@navigator.register(Server, "Insights")
class CloudInsightsServices(CFMENavigateStep):
VIEW = CloudInsightsServicesView
prerequisite = NavigateToSibling("LoggedIn")

def step(self, *args, **kwargs):
self.view.navigation.select("Red Hat Cloud", "Services")
6 changes: 6 additions & 0 deletions cfme/cloud_insights/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
"""This is a directory of modules, each one represents one menu sub-item.

* :py:mod:`cfme.cloud_insights.services`
* :py:mod:`cfme.cloud_insights.providers`
"""
76 changes: 76 additions & 0 deletions cfme/cloud_insights/providers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
""" A model of an Infrastructure Provider in CFME
"""
import attr
from navmazing import NavigateToAttribute
from widgetastic.widget import Checkbox
from widgetastic.widget import Text
from widgetastic_patternfly import Button
from widgetastic_patternfly import Input
from widgetastic_patternfly import SelectorDropdown

from cfme.base.login import BaseLoggedInPage
from cfme.infrastructure.host import HostsCollection
from cfme.modeling.base import BaseCollection
from cfme.modeling.base import BaseEntity
from cfme.utils.appliance.implementations.ui import CFMENavigateStep
from cfme.utils.appliance.implementations.ui import navigate_to
from cfme.utils.appliance.implementations.ui import navigator
from widgetastic_manageiq import Table
# from cfme.exceptions import displayed_not_implemented


class CloudInsightsProvidersView(BaseLoggedInPage):
"""Basic view for Red Hat Cloud/Services page."""

global_sync_title = Text(locator='.//h1[normalize-space(.)="Global Synchronization"]')
global_sync_subtext = Text(locator='.//p[@id="red_hat_cloud_providers_global_info"')
sync_platform_button = Button("Synchronize this Platform to Cloud")
provider_sync_title = Text(locator='.//h1[normalize-space(.)="Provider Synchronization"]')
provider_sync_subtext = Text('.//p[@id="red_hat_cloud_services_table_info"')
filter_dropdown = SelectorDropdown("id", "filter_input")
filter_input_field = Input(id='filter_input')
sync_table_button = Button(id="Synchronize")
provider_sync_table = Table(
'.//table[@id="red_hat_cloud_providers_table")]',
column_widgets={
0: Checkbox(locator=".//input[@type='checkbox']"),
"Action": Button(location='.//td/button[normalize-space(text())="Synchronize"]'),
},
)

@property
def is_displayed(self):
return (self.global_sync_title.text == "Global Synchronization"
and self.sync_platform_button.is_displayed
and self.provider_sync_title == "Provider Synchronization"
and self.provider_sync_table.is_displayed)


@attr.s
class CloudInsightsProviders(BaseEntity):

provider = attr.ib(default=None)

_collections = {'hosts': HostsCollection}


@attr.s
class CloudInsightsProvidersCollection(BaseCollection):

ENTITY = CloudInsightsProviders

def all(self):
view = navigate_to(self, "All")
providers = [self.collections.instantiate(name=row.name.text) for row in
view.provider_sync_table.rows()]
return providers


# Red Hat Cloud - Insights
@navigator.register(CloudInsightsProvidersCollection, "All")
class CloudInsightsServices(CFMENavigateStep):
VIEW = CloudInsightsProvidersView
prerequisite = NavigateToAttribute('appliance.server', 'LoggedIn')

def step(self, *args, **kwargs):
self.view.navigation.select("Red Hat Cloud", "Providers")
17 changes: 17 additions & 0 deletions cfme/cloud_insights/services.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from widgetastic.widget import Text
from widgetastic_patternfly import Button

from cfme.base.login import BaseLoggedInPage


class CloudInsightsServicesView(BaseLoggedInPage):
"""Basic view for Red Hat Cloud/Services page."""
title = Text('//div[@id="red_hat_cloud_services_redirect"]//h1')
subtext = Text(locator='.//p[@id="red_hat_cloud_services_redirect_info"')
take_me_button = Button("Take me there")

@property
def is_displayed(self):
return (
self.title.text == "Services" and self.take_me_button.is_displayed
)
1 change: 1 addition & 0 deletions entry_points.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ cloud_av_zones = cfme.cloud.availability_zone:AvailabilityZoneCollection
cloud_flavors = cfme.cloud.flavor:FlavorCollection
cloud_host_aggregates = cfme.cloud.host_aggregates:HostAggregatesCollection
cloud_images = cfme.cloud.instance.image:ImageCollection
cloud_insights_providers = cfme.cloud_insights.providers:CloudInsightsProvidersCollection
cloud_instances = cfme.cloud.instance:InstanceCollection
cloud_keypairs = cfme.cloud.keypairs:KeyPairCollection
cloud_networks = cfme.networks.cloud_network:CloudNetworkCollection
Expand Down