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

Commit

Permalink
Fix test interation in test_providers
Browse files Browse the repository at this point in the history
test_bad_credentials was leaving the browser on the add provider form

subsequent tests were breaking, as the browser would not navigate away.
  • Loading branch information
mshriver committed Sep 16, 2019
1 parent ec2719a commit 90f77ba
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions cfme/tests/cloud/test_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def test_add_cancelled_validation_cloud(request, appliance):
@pytest.mark.tier(3)
@pytest.mark.usefixtures('has_no_cloud_providers')
@test_requirements.discovery
def test_cloud_provider_add_with_bad_credentials(provider, enable_regions):
def test_cloud_provider_add_with_bad_credentials(request, provider, enable_regions, appliance):
""" Tests provider add with bad credentials
Metadata:
Expand Down Expand Up @@ -242,6 +242,14 @@ def test_cloud_provider_add_with_bad_credentials(provider, enable_regions):
if endp_name != 'default':
del provider.endpoints[endp_name]

@request.addfinalizer
def clear_form():
from cfme.common.provider_views import ProviderAddView
view = appliance.browser.create_view(ProviderAddView)
if view.is_displayed:
view.cancel.click()
assert not view.is_displayed

with pytest.raises(Exception, match=flash):
provider.create(validate_credentials=True)

Expand Down Expand Up @@ -698,10 +706,11 @@ def test_display_network_topology(appliance, openstack_provider):
view.flash.assert_no_error()


@pytest.mark.provider([CloudProvider], scope='class', override=True)
class TestProvidersRESTAPI(object):
@pytest.mark.tier(3)
@pytest.mark.parametrize('from_detail', [True, False], ids=['from_detail', 'from_collection'])
def test_cloud_networks_query(self, cloud_provider, appliance, from_detail, setup_provider):
def test_cloud_networks_query(self, provider, appliance, from_detail, setup_provider):
"""Tests querying cloud providers and cloud_networks collection for network info.
Metadata:
Expand All @@ -714,11 +723,11 @@ def test_cloud_networks_query(self, cloud_provider, appliance, from_detail, setu
initialEstimate: 1/3h
"""
if from_detail:
networks = appliance.rest_api.collections.providers.get(
name=cloud_provider.name).cloud_networks
networks = provider.rest_api_entity.cloud_networks
else:
networks = appliance.rest_api.collections.cloud_networks
assert_response(appliance)
assert len(networks) > 0, 'No cloud networks found'
assert networks.name == 'cloud_networks'
assert len(networks.all) == networks.subcount

Expand All @@ -731,7 +740,7 @@ def test_cloud_networks_query(self, cloud_provider, appliance, from_detail, setu
assert enabled_networks >= 1

@pytest.mark.tier(3)
def test_security_groups_query(self, cloud_provider, appliance, setup_provider):
def test_security_groups_query(self, provider, appliance, setup_provider):
"""Tests querying cloud networks subcollection for security groups info.
Metadata:
Expand All @@ -743,8 +752,10 @@ def test_security_groups_query(self, cloud_provider, appliance, setup_provider):
caseimportance: low
initialEstimate: 1/4h
"""
network = appliance.rest_api.collections.providers.get(
name=cloud_provider.name).cloud_networks[0]
try:
network = provider.rest_api_entity.cloud_networks[0]
except IndexError:
pytest.fail(f'No networks found on cloud provider {provider}')
network.reload(attributes='security_groups')
security_groups = network.security_groups
# "security_groups" needs to be present, even if it's just an empty list
Expand Down

0 comments on commit 90f77ba

Please sign in to comment.