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

Commit

Permalink
[RFR] Parametrize Tower tests on API version (#9888)
Browse files Browse the repository at this point in the history
* Parametrize Tower tests on API version

* Parametrize Tower tests on API version

* Parametrize Tower tests on API version

* Parametrize Tower tests on API version

* Parametrize Tower tests on API version
  • Loading branch information
nachandr authored Jan 31, 2020
1 parent 5aa87c9 commit 3250c91
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 14 deletions.
30 changes: 30 additions & 0 deletions cfme/fixtures/ansible_tower.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from urllib.parse import urlparse

import fauxfactory
import pytest

from cfme.rest.gen_data import _creating_skeleton
from cfme.utils.blockers import GH
from cfme.utils.update import update


def ansible_tower_dialog_rest(request, appliance):
Expand Down Expand Up @@ -124,3 +127,30 @@ def ansible_tower_dialog(request, appliance):

if appliance.version < '5.11' or not GH(8836).blocks:
service_dialog.delete_if_exists()


@pytest.fixture
def ansible_api_version_change(provider, ansible_api_version):
"""
Fixture to update Tower url to /api/vx in the UI so that all supported versions of API
can be tested.
API version defaults to v1. So, if no version is specified, v1 is used except for things
which don't exist on v1.
If v2 is specified, v2 is used for everything.
Ansible Tower 3.4, 3.5 support both API v1 and v2.
API v1 has been fully deprecated in Ansible Tower 3.6 and Tower 3.6 supports API v2 only.
"""
original_url = provider.url
parsed = urlparse(provider.url)

updated_url = f'{parsed.scheme}://{parsed.netloc}/api/{ansible_api_version}'
with update(provider, validate_credentials=True):
provider.url = updated_url

yield

with update(provider, validate_credentials=True):
provider.url = original_url
5 changes: 3 additions & 2 deletions cfme/infrastructure/config_management/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,14 @@ def update(self, updates, cancel=False, validate_credentials=False):
if validate_credentials:
view.entities.form.validate.click()
view.flash.assert_success_message('Credential validation was successful')
if cancel:
if cancel or view.entities.save.disabled:
view.entities.cancel.click()
view.flash.assert_success_message('Edit of Provider was cancelled by the user')
else:
view.entities.save.click()
view.flash.assert_success_message(
'{} Provider "{}" was updated'.format(self.ui_type, updates['name'] or self.name))
'{} Provider "{}" was updated'.format(self.ui_type,
updates.get('name') or self.name))
self.__dict__.update(**updates)

def delete(self, cancel=False, wait_deleted=True, force=False):
Expand Down
13 changes: 8 additions & 5 deletions cfme/tests/services/test_ansible_workflow_servicecatalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
pytest.mark.tier(2),
pytest.mark.provider([AnsibleTowerProvider], scope='module'),
pytest.mark.usefixtures('setup_provider'),
pytest.mark.parametrize('workflow_type', ['multiple_job_workflow', 'inventory_sync_workflow'],
ids=['multiple_job_workflow', 'inventory_sync_workflow'],
scope='module'),
pytest.mark.parametrize('ansible_api_version', ['v1', 'v2']),
pytest.mark.ignore_stream('upstream')
]

Expand All @@ -41,8 +39,11 @@ def ansible_workflow_catitem(appliance, provider, dialog, catalog, workflow_type
catalog_item.delete_if_exists()


@pytest.mark.parametrize('workflow_type', ['multiple_job_workflow', 'inventory_sync_workflow'],
ids=['multiple_job_workflow', 'inventory_sync_workflow'], scope='module')
@pytest.mark.meta(automates=[BZ(1719051)])
def test_tower_workflow_item(appliance, ansible_workflow_catitem):
def test_tower_workflow_item(appliance, ansible_workflow_catitem, workflow_type,
ansible_api_version_change):
"""Tests ordering of catalog items for Ansible Workflow templates
Metadata:
test_flag: provision
Expand All @@ -68,7 +69,9 @@ def test_tower_workflow_item(appliance, ansible_workflow_catitem):
)


def test_retire_ansible_workflow(appliance, ansible_workflow_catitem):
@pytest.mark.parametrize('workflow_type', ['multiple_job_workflow'], ids=['multiple_job_workflow'])
def test_retire_ansible_workflow(appliance, ansible_workflow_catitem, workflow_type,
ansible_api_version_change):
"""Tests retiring of catalog items for Ansible Workflow templates
Metadata:
test_flag: provision
Expand Down
18 changes: 11 additions & 7 deletions cfme/tests/services/test_config_provider_servicecatalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@
pytest.mark.provider([AnsibleTowerProvider], scope='module'),
pytest.mark.usefixtures('setup_provider'),
pytest.mark.tier(2),
pytest.mark.parametrize('job_type', ['template', 'template_limit', 'template_survey',
'textarea_survey'],
ids=['template_job', 'template_limit_job', 'template_survey_job', 'textarea_survey_job'],
scope='module'),
pytest.mark.ignore_stream('upstream'),
pytest.mark.parametrize('ansible_api_version', ['v1', 'v2']),
pytest.mark.ignore_stream('upstream')
]


Expand All @@ -39,9 +36,14 @@ def catalog_item(appliance, request, provider, ansible_tower_dialog, catalog, jo
return catalog_item


@pytest.mark.parametrize('job_type', ['template', 'template_limit', 'template_survey',
'textarea_survey'],
ids=['template_job', 'template_limit_job', 'template_survey_job', 'textarea_survey_job'],
scope='module')
@pytest.mark.meta(automates=[BZ(1717500)])
# The 'textarea_survey' job type automates BZ 1717500
def test_order_tower_catalog_item(appliance, provider, catalog_item, request, job_type):
def test_order_tower_catalog_item(appliance, provider, catalog_item, request, job_type,
ansible_api_version_change):
"""Tests ordering of catalog items for Ansible Template and Workflow jobs
Metadata:
test_flag: provision
Expand Down Expand Up @@ -74,7 +76,9 @@ def test_order_tower_catalog_item(appliance, provider, catalog_item, request, jo
'List View')


def test_retire_ansible_service(appliance, catalog_item, request, job_type):
@pytest.mark.parametrize('job_type', ['template'], ids=['template_job'])
def test_retire_ansible_service(appliance, catalog_item, request, job_type,
ansible_api_version_change):
"""Tests retiring of catalog items for Ansible Template and Workflow jobs
Metadata:
test_flag: provision
Expand Down

0 comments on commit 3250c91

Please sign in to comment.