From 6bd3a30b12727df252dac47b129140bbb4112915 Mon Sep 17 00:00:00 2001 From: Parthvi Vala Date: Mon, 16 Dec 2019 16:47:27 +0530 Subject: [PATCH] [WIPTEST] Automate: test_service_refresh_dialog_fields_default_values --- cfme/automate/dialogs/service_dialogs.py | 10 ++++ cfme/tests/services/test_rest_services.py | 65 +++++++++++++++++++++++ cfme/tests/test_rest_manual.py | 39 -------------- 3 files changed, 75 insertions(+), 39 deletions(-) diff --git a/cfme/automate/dialogs/service_dialogs.py b/cfme/automate/dialogs/service_dialogs.py index 551fe1ac33..76b6432cc4 100644 --- a/cfme/automate/dialogs/service_dialogs.py +++ b/cfme/automate/dialogs/service_dialogs.py @@ -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 @@ -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): diff --git a/cfme/tests/services/test_rest_services.py b/cfme/tests/services/test_rest_services.py index 33e19c48eb..a561917e0a 100644 --- a/cfme/tests/services/test_rest_services.py +++ b/cfme/tests/services/test_rest_services.py @@ -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( + 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.", + ) diff --git a/cfme/tests/test_rest_manual.py b/cfme/tests/test_rest_manual.py index 51ad955f63..d43706bbc8 100644 --- a/cfme/tests/test_rest_manual.py +++ b/cfme/tests/test_rest_manual.py @@ -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(