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

[1LP][RFR] Automate: test_service_refresh_dialog_fields_default_values #9770

Merged
merged 1 commit into from
Dec 18, 2019
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
10 changes: 10 additions & 0 deletions cfme/automate/dialogs/service_dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from cfme.automate.dialogs import AutomateCustomizationView
from cfme.automate.dialogs import EditDialogView
from cfme.automate.dialogs.dialog_tab import TabCollection
from cfme.exceptions import RestLookupError
from cfme.modeling.base import BaseCollection
from cfme.modeling.base import BaseEntity
from cfme.utils.appliance.implementations.ui import CFMENavigateStep
Expand Down Expand Up @@ -89,6 +90,15 @@ def delete(self):
view.flash.assert_success_message(
'Dialog "{}": Delete successful'.format(self.label))

@property
def rest_api_entity(self):
try:
return self.appliance.rest_api.collections.service_dialogs.get(label=self.label)
except ValueError:
raise RestLookupError(
f"No service dialog rest entity found matching label {self.label}"
)


@attr.s
class DialogCollection(BaseCollection):
Expand Down
65 changes: 65 additions & 0 deletions cfme/tests/services/test_rest_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -2434,3 +2434,68 @@ def test_embedded_ansible_cat_item_edit_rest(appliance, request, ansible_catalog
service_template.reload()
assert service_template.name == new_data["name"]
assert service_template.description == new_data["description"]


@pytest.mark.meta(automates=[1730813])
@test_requirements.rest
@pytest.mark.customer_scenario
@pytest.mark.parametrize("file_name", ["testgear-dialog.yaml"], ids=[''])
def test_service_refresh_dialog_fields_default_values(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional:
Don't you think we need add something in ids?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test name will be like test_service_refresh_dialog_fields_default_values[infra], so I'm okay with not giving it any ID here. Besides, I couldn't think of any good ID name so I kept it empty.

appliance, request, file_name, import_dialog, soft_assert
):
"""
Bugzilla:
1730813
1731977

Polarion:
assignee: pvala
caseimportance: high
casecomponent: Rest
initialEstimate: 1/4h
setup:
1. Import dialog `RTP Testgear Client Provision` from the BZ attachments and create
a service_template and service catalog to attach it.
testSteps:
1. Perform action `refresh_dialog_fields` by sending a request
POST /api/service_catalogs/<:id>/sevice_templates/<:id>
{
"action": "refresh_dialog_fields",
"resource": {
"fields": [
"tag_1_region",
"tag_0_function"
]
}
}
expectedResults:
1. Request must be successful and evm must have the default values
for the fields mentioned in testStep 1.
"""
dialog, _ = import_dialog
service_template = _service_templates(
request, appliance, service_dialog=dialog.rest_api_entity, num=1
)[0]

# We cannot directly call `refresh_dialog_fields` action from service_template, it has to be
# accessed via service_catalog.
service_catalog = appliance.rest_api.collections.service_catalogs.get(
id=service_template.service_template_catalog_id
)
service_catalog.service_templates.get(id=service_template.id).action.refresh_dialog_fields(
**{"fields": ["tag_1_region", "tag_0_function"]}
)
assert_response(appliance)

response = appliance.rest_api.response.json()["result"]
expected_tag_1_region = [["rtp", "rtp-vaas-vc.cisco.com"]]
expected_tag_0_function = [["ixia", "IXIA"]]

soft_assert(
expected_tag_1_region == response["tag_1_region"]["values"],
"Default values for 'tag_1_region' did not match.",
)
soft_assert(
expected_tag_0_function == response["tag_0_function"]["values"],
"Default values for 'tag_0_function' did not match.",
)
39 changes: 0 additions & 39 deletions cfme/tests/test_rest_manual.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,45 +88,6 @@ def test_widget_generate_content_via_rest(context):
pass


@pytest.mark.meta(coverage=[1730813])
@pytest.mark.tier(2)
@test_requirements.rest
@pytest.mark.customer_scenario
def test_service_refresh_dialog_fields_default_values():
"""
Bugzilla:
1730813
1731977

Polarion:
assignee: pvala
caseimportance: high
casecomponent: Rest
initialEstimate: 1/4h
setup:
1. Import dialog `RTP Testgear Client Provision` from the BZ attachments and create
a service_template and service catalog to attach it.
testSteps:
1. Start monitoring the evm log and look for fields `tag_1_region` and `tag_0_function`.
2. Perform action `refresh_dialog_fields` by sending a request
POST /api/service_catalogs/<:id>/sevice_templates/<:id>
{
"action": "refresh_dialog_fields",
"resource": {
"fields": [
"tag_1_region",
"tag_0_function"
]
}
}
expectedResults:
1.
2. Request must be successful and evm must have the default values
for the fields mentioned in testStep 1.
"""
pass


@pytest.mark.tier(2)
@pytest.mark.meta(coverage=[1486765, 1740340])
@pytest.mark.parametrize(
Expand Down