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

Commit

Permalink
Automate: test_service_select_tenants
Browse files Browse the repository at this point in the history
  • Loading branch information
valaparthvi committed May 18, 2020
1 parent de3323e commit 342c08e
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 17 deletions.
78 changes: 72 additions & 6 deletions cfme/services/catalogs/catalog_items/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from widgetastic_patternfly import BootstrapSelect
from widgetastic_patternfly import Button
from widgetastic_patternfly import CandidateNotFound
from widgetastic_patternfly import CheckableBootstrapTreeview
from widgetastic_patternfly import Input

from cfme.common import Taggable
Expand All @@ -38,6 +39,7 @@
from widgetastic_manageiq import FileInput
from widgetastic_manageiq import FonticonPicker
from widgetastic_manageiq import ManageIQTree
from widgetastic_manageiq import SummaryForm
from widgetastic_manageiq import SummaryFormItem
from widgetastic_manageiq import SummaryTable
from widgetastic_manageiq import Table
Expand Down Expand Up @@ -75,6 +77,10 @@ class BasicInfoForm(ServicesCatalogView):
"5.11": EntryPoint(name='reconfigure_fqname', tree_id="automate_catalog_treebox")
})
select_resource = BootstrapSelect('resource_id')
additional_tenants = CheckableBootstrapTreeview(tree_id="tenants_treebox")
zone = BootstrapSelect("zone_id")
currency = BootstrapSelect("currency")
price_per_month = Input(name="price")

@View.nested
class modal(View): # noqa
Expand Down Expand Up @@ -162,6 +168,7 @@ class DetailsEntitiesCatalogItemView(View):

class DetailsCatalogItemView(ServicesCatalogView):
title = Text('#explorer_title_text')
basic_info = SummaryForm("Basic Information")

@property
def is_displayed(self):
Expand Down Expand Up @@ -492,6 +499,44 @@ def catalog_name(self):
cat_name = 'My Company/{}'.format(getattr(self.catalog, 'name', None))
return cat_name

@staticmethod
def set_additional_tenants(view, tenants):
""" Sets additional tenants
Args:
view: AddCatalogItemView or EditCatalogItemView
tenants: list of tenants with options to select
Usage:
set True to the path which needs to be checked
and False for the path that needs to be unchecked
catalog_item = appliance.collections.catalog_items.create(
catalog_item_class,
additional_tenants=[
(("All Tenants"), False),
(("All Tenants", "My Company"), True),
(("All Tenants", "My Company", "Child", "Grandchild"), True),
],
*args,
**kwargs
)
"""
if tenants is not None and isinstance(tenants, (list, tuple, set)):
changes = [
view.fill(
{
"additional_tenants": CheckableBootstrapTreeview.CheckNode(path)
if option
else CheckableBootstrapTreeview.UncheckNode(path)
}
)
for path, option in tenants
]
return True in changes
else:
return False


@attr.s
class CloudInfraCatalogItem(BaseCatalogItem):
Expand All @@ -508,6 +553,10 @@ class CloudInfraCatalogItem(BaseCatalogItem):
provisioning_entry_point = attr.ib(default=None)
retirement_entry_point = attr.ib(default=None)
reconfigure_entry_point = attr.ib(default=None)
zone = attr.ib(default=None)
currency = attr.ib(default=None)
price_per_month = attr.ib(default=None)
additional_tenants = attr.ib(default=None)

@property
def fill_dict(self):
Expand All @@ -516,11 +565,15 @@ def fill_dict(self):
'name': self.name,
'description': self.description,
'display': self.display_in,
'select_catalog': self.catalog_name,
'select_catalog': self.catalog_name if self.catalog else "<Unassigned>",
'select_dialog': self.dialog,
'provisioning_entry_point': self.provisioning_entry_point,
'retirement_entry_point': self.retirement_entry_point,
'reconfigure_entry_point': self.reconfigure_entry_point
'reconfigure_entry_point': self.reconfigure_entry_point,
"additional_tenants": self.additional_tenants,
"zone": self.zone,
"currency": self.currency,
"price_per_month": self.price_per_month
},
'request_info': {'provisioning': self.prov_data}
}
Expand All @@ -540,18 +593,26 @@ class NonCloudInfraCatalogItem(BaseCatalogItem):
provisioning_entry_point = attr.ib(default=None)
retirement_entry_point = attr.ib(default=None)
reconfigure_entry_point = attr.ib(default=None)
zone = attr.ib(default=None)
currency = attr.ib(default=None)
price_per_month = attr.ib(default=None)
additional_tenants = attr.ib(default=None)

@cached_property
def _fill_dict(self):
return {
'name': self.name,
'description': self.description,
'display': self.display_in,
'select_catalog': self.catalog_name,
'select_catalog': self.catalog_name if self.catalog else "<Unassigned>",
'select_dialog': self.dialog,
'provisioning_entry_point': self.provisioning_entry_point,
'retirement_entry_point': self.retirement_entry_point,
'reconfigure_entry_point': self.reconfigure_entry_point
'reconfigure_entry_point': self.reconfigure_entry_point,
"additional_tenants": self.additional_tenants,
"zone": self.zone,
"currency": self.currency,
"price_per_month": self.price_per_month
}


Expand Down Expand Up @@ -668,11 +729,16 @@ def create(self, catalog_item_class, *args, **kwargs):
Returns:
An instance of catalog_item_class
"""
cat_item = self.instantiate(catalog_item_class, *args, **kwargs)
additional_tenants = kwargs.pop("additional_tenants", None)

cat_item = self.instantiate(catalog_item_class, * args, **kwargs)
view = navigate_to(cat_item, "Add")
if additional_tenants:
cat_item.set_additional_tenants(view, additional_tenants)
view.fill(cat_item.fill_dict)
cat_item.additional_tenants = additional_tenants
view.add.click()
view = self.create_view(AllCatalogItemView, wait='10s')
view = self.create_view(AllCatalogItemView, wait="10s")
view.flash.assert_no_error()
return cat_item

Expand Down
50 changes: 39 additions & 11 deletions cfme/tests/services/test_catalog_item.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import fauxfactory
import pytest
from selenium.common.exceptions import NoSuchElementException
from widgetastic_patternfly import CheckableBootstrapTreeview

import cfme.tests.configure.test_access_control as tac
from cfme import test_requirements
from cfme.common import BaseLoggedInPage
from cfme.rest.gen_data import tenants as _tenants
from cfme.services.catalogs.catalog_items import AddCatalogItemView
from cfme.services.catalogs.catalog_items import AllCatalogItemView
from cfme.services.catalogs.catalog_items import DetailsCatalogItemView
Expand Down Expand Up @@ -79,6 +81,11 @@ def _check_catalog_visibility(test_item_object):
return _check_catalog_visibility


@pytest.fixture
def tenant(appliance, request):
return _tenants(request, appliance)


def test_catalog_item_crud(appliance, dialog, catalog):
"""
Polarion:
Expand Down Expand Up @@ -419,28 +426,49 @@ def test_copy_catalog_item(request, generic_catalog_item):
assert new_cat_item.exists


@pytest.mark.meta(coverage=[1678123])
@pytest.mark.manual
@pytest.mark.meta(automates=[1678123])
@pytest.mark.tier(2)
def test_service_select_tenants():
@pytest.mark.ignore_stream("5.10")
def test_service_select_tenants(appliance, request, tenant):
"""
Bugzilla:
1678123
Polarion:
assignee: nansari
casecomponent: Services
initialEstimate: 1/6h
startsin: 5.11
setup:
1. Create a tenant.
testSteps:
1. Create catalog
2. Create catalog item with tenants
3. login with tenant and check the services
1. Create catalog item with the given tenant
expectedResults:
1.
2.
3. Services Should be visible to Tenant
"""
pass
1. Catalog item is created successfully
and tenant is visible under catalog items's Details page
"""
tenants_path = ("All Tenants", "My Company", tenant.name)
data = {
"name": fauxfactory.gen_alphanumeric(start="cat_item_", length=15),
"description": fauxfactory.gen_alphanumeric(start="cat_item_desc_", length=20),
"zone": "Default Zone",
"currency": "$ [Australian Dollar]",
"price_per_month": 100,
"additional_tenants": [(tenants_path, True)],
}

catalog_item = appliance.collections.catalog_items.create(
appliance.collections.catalog_items.GENERIC, **data
)
request.addfinalizer(catalog_item.delete)

view = navigate_to(catalog_item, "Details")

# Defining this widget so that we can expand the required tenants path
additional_tenants = CheckableBootstrapTreeview(view, tree_id="tenants_treebox")
# Make sure the required path is visible i.e not collapsed
additional_tenants.expand_path(*tenants_path)
assert tenant.name in view.basic_info.get_text_of("Additional Tenants")


@test_requirements.service
Expand Down

0 comments on commit 342c08e

Please sign in to comment.