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

[1LP][RFR] Adding copy catalog bundle #9980

Merged
merged 1 commit into from
Mar 13, 2020
Merged
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
41 changes: 41 additions & 0 deletions cfme/services/catalogs/catalog_items/catalog_bundles.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from widgetastic.widget import View
from widgetastic_patternfly import BootstrapSelect
from widgetastic_patternfly import Button
from widgetastic_patternfly import Input

from cfme.modeling.base import BaseCollection
from cfme.services.catalogs.catalog_items import AllCatalogItemView
Expand Down Expand Up @@ -61,6 +62,21 @@ def is_displayed(self):
)


class CopyCatalogBundleView(CatalogBundleFormView):
name = Input(name="name")

add = Button("Add")
cancel = Button("Cancel")

@property
def is_displayed(self):
return (
self.title.text == f'Service Catalog Item "{self.context["object"].name}"'
and self.catalog_items.is_opened
and self.catalog_items.is_dimmed
)


@attr.s
class CatalogBundle(NonCloudInfraCatalogItem):

Expand All @@ -82,6 +98,22 @@ def update(self, updates):
view = self.create_view(DetailsCatalogItemView, override=updates, wait='10s')
view.flash.assert_no_error()

def copy(self, name=None):
view = navigate_to(self, 'Copy')

# there is default name like `Copy of *`
if name:
view.name.fill(name)

copied_name = view.name.value
view.add.click()
view.flash.assert_no_error()

# Catalog bundle can be any type
item_args = self.__dict__
item_args["name"] = copied_name
return self.__class__(**item_args)


@attr.s
class CatalogBundlesCollection(BaseCollection):
Expand Down Expand Up @@ -146,3 +178,12 @@ class BundleEdit(CFMENavigateStep):

def step(self, *args, **kwargs):
self.prerequisite_view.configuration.item_select('Edit this Item')


@navigator.register(CatalogBundle, "Copy")
class CatalogBundleCopyStep(CFMENavigateStep):
VIEW = CopyCatalogBundleView
prerequisite = NavigateToSibling("Details")

def step(self, *args, **kwargs):
self.prerequisite_view.configuration.item_select("Copy Selected Item")
17 changes: 13 additions & 4 deletions cfme/tests/services/test_generic_service_catalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,14 @@ def test_edit_multiple_service_catalogs(self, appliance, service_catalogs):
assert scl.name == new_names[index]


@pytest.mark.meta(coverage=[1678149])
@pytest.mark.manual
@pytest.mark.meta(automates=[1678149])
@pytest.mark.ignore_stream('5.10')
@pytest.mark.tier(2)
def test_copy_catalog_bundle():
def test_copy_catalog_bundle(appliance, request, generic_catalog_item):
"""
Bugzilla:
1678149

Polarion:
assignee: nansari
casecomponent: Services
Expand All @@ -291,7 +291,16 @@ def test_copy_catalog_bundle():
2.
3. Able to copy catalog Bundle
"""
pass
bundle_name = fauxfactory.gen_alphanumeric(15, start="cat_bundle_")
catalog_bundle = appliance.collections.catalog_bundles.create(
bundle_name, description="catalog_bundle",
display_in=True, catalog=generic_catalog_item.catalog,
dialog=generic_catalog_item.dialog,
catalog_items=[generic_catalog_item.name])

# copy catalog item
new_cat_bundle = catalog_bundle.copy()
request.addfinalizer(new_cat_bundle.delete_if_exists)


@pytest.mark.meta(coverage=[1671522])
Expand Down