This repository has been archived by the owner on Apr 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 165
[RFR] Parametrize Tower tests on API version #9888
Merged
mshriver
merged 5 commits into
ManageIQ:master
from
nachandr:parametrize_tower_tests_on_api_version
Jan 31, 2020
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7efa1b5
Parametrize Tower tests on API version
nachandr 94123a4
Parametrize Tower tests on API version
nachandr dace9b1
Parametrize Tower tests on API version
nachandr 0134647
Parametrize Tower tests on API version
nachandr 445388f
Parametrize Tower tests on API version
nachandr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): | ||
|
@@ -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/v2 so that API v2 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. | ||
|
||
""" | ||
parsed = urlparse(provider.url) | ||
|
||
if ansible_api_version == 'v2': | ||
updated_url = f'{parsed.scheme}://{parsed.netloc}/api/{ansible_api_version}' | ||
original_url = provider.url | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking good, but I would do two things here:
If we're not explicitly setting it, we risk running into situations where fixture/parameter scope, or the URL defined for the provider in the yaml, will result in the provider's configuration not matching the parametrized value for API. This way we can remove the logic here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
with update(provider, validate_credentials=True): | ||
provider.url = updated_url | ||
|
||
yield | ||
|
||
if ansible_api_version != 'v1': | ||
with update(provider, validate_credentials=True): | ||
provider.url = original_url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌 Thanks for the thorough docblock!