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

[1LP][RFR] Rewrite of test_infrastructure_hosts_crud for only single hosts #9761

Merged
merged 14 commits into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from 11 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
7 changes: 5 additions & 2 deletions cfme/infrastructure/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,17 @@ def __init__(self, **kwargs):
super(Host.Credential, self).__init__(**kwargs)
self.ipmi = kwargs.get('ipmi')

def update(self, updates, validate_credentials=False):
def update(self, updates, validate_credentials=False, from_details=False):
"""Updates a host in the UI. Better to use utils.update.update context manager than call
this directly.

Args:
updates (dict): fields that are changing.
"""

if from_details:
view = navigate_to(self, "Details")
else:
view = navigate_to(self.parent, "All")
view = navigate_to(self, "Edit")
changed = view.fill({
"name": updates.get("name"),
Expand Down
40 changes: 20 additions & 20 deletions cfme/tests/infrastructure/test_host.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import random
import socket

import fauxfactory
import pytest
from wait_for import TimedOutError
from widgetastic.exceptions import UnexpectedAlertPresentException

from cfme import test_requirements
from cfme.base.credential import Credential
from cfme.common.host_views import HostsCompareView
from cfme.common.host_views import HostsEditView
from cfme.common.host_views import ProviderHostsCompareView
from cfme.common.provider_views import InfraProviderDetailsView
from cfme.common.provider_views import InfraProvidersView
from cfme.common.provider_views import ProviderNodesView
from cfme.fixtures.provider import setup_or_skip
from cfme.infrastructure.provider import InfraProvider
Expand Down Expand Up @@ -541,28 +540,29 @@ def test_add_ipmi_refresh(appliance, setup_provider):


@test_requirements.infra_hosts
@pytest.mark.parametrize("num_hosts", [1, 2, 4])
@pytest.mark.meta(blockers=[BZ(1634794, forced_streams=["5.10"])], automates=[1634794])
def test_infrastructure_hosts_crud(appliance, setup_provider_min_hosts, provider, num_hosts):
@pytest.mark.parametrize("crud_action", ['edit_from_hosts', 'edit_from_details', 'remove'])
def test_infrastructure_hosts_crud(appliance, setup_provider, provider, crud_action):
"""
Polarion:
assignee: prichard
casecomponent: Infra
caseimportance: low
initialEstimate: 1/6h
Bugzilla:
1634794
"""
my_slice = slice(0, num_hosts, None)
hosts_view = navigate_to(provider.collections.hosts, "All")
for h in hosts_view.entities.get_all(slice=my_slice):
h.ensure_checked()
hosts_view.toolbar.configuration.item_select('Edit Selected items',
handle_alert=False)
try:
hosts_view.navigation.select('Compute', 'Infrastructure', 'Providers', handle_alert=False)
final_view = provider.create_view(InfraProvidersView)
assert final_view.is_displayed
except UnexpectedAlertPresentException:
pytest.fail("Abandon changes alert displayed, but no changes made.")
# TODO add additional crud functionality.
from cfme.utils.update import update
Copy link
Contributor

Choose a reason for hiding this comment

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

can you move this to the top of the file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


host = appliance.collections.hosts.all()[0]
if crud_action != 'remove':
stamp = fauxfactory.gen_alphanumeric()
new_custom_id = f'Edit host data. {stamp}'

# with update(host, from_details=lambda crud_action: crud_action=='edit_from_details'):
with update(host, from_details=(crud_action == 'edit_from_details')):
host.custom_ident = new_custom_id

assert host.custom_ident == new_custom_id
Copy link
Member

Choose a reason for hiding this comment

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

Don't trust the update context manager I see... :)

assert navigate_to(host, 'Details').entities.summary("Properties").get_text_of(
"Custom Identifier") == new_custom_id
else:
host.delete()
host.delete(cancel=False)