diff --git a/cfme/common/host_views.py b/cfme/common/host_views.py index d5ab70a860..f874a92977 100644 --- a/cfme/common/host_views.py +++ b/cfme/common/host_views.py @@ -11,7 +11,6 @@ from cfme.common import BaseLoggedInPage from cfme.common import TimelinesView -from cfme.exceptions import displayed_not_implemented from cfme.utils.log import logger from cfme.utils.version import Version from cfme.utils.version import VersionPicker @@ -302,8 +301,13 @@ class HostEditView(HostFormView): breadcrumb = BreadCrumb() save_button = Button("Save") reset_button = Button("Reset") + cancel_button = Button("Cancel") - is_displayed = displayed_not_implemented + @property + def is_displayed(self): + return ( + self.logged_in_as_current_user and self.navigation.currently_selected == [ + 'Compute', 'Infrastructure', 'Hosts'] and self.title.text == 'Info/Settings') class HostsEditView(HostEditView): diff --git a/cfme/infrastructure/host.py b/cfme/infrastructure/host.py index a5cbce0fcd..80d4ec56b3 100644 --- a/cfme/infrastructure/host.py +++ b/cfme/infrastructure/host.py @@ -92,15 +92,21 @@ 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=True): """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. """ - - view = navigate_to(self, "Edit") + if from_details: + view = navigate_to(self, "Edit") + else: + view = navigate_to(self.parent, "All") + view.entities.get_entity(name=self.name, surf_pages=True).ensure_checked() + view.toolbar.configuration.item_select('Edit Selected items') + view = self.create_view(HostEditView) + assert view.is_displayed changed = view.fill({ "name": updates.get("name"), "hostname": updates.get("hostname") or updates.get("ip_address"), diff --git a/cfme/tests/infrastructure/test_host.py b/cfme/tests/infrastructure/test_host.py index ef8561d9bb..f1caf68c7f 100644 --- a/cfme/tests/infrastructure/test_host.py +++ b/cfme/tests/infrastructure/test_host.py @@ -1,9 +1,9 @@ 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 @@ -11,7 +11,6 @@ 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 @@ -541,28 +540,26 @@ 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, 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. + 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=(crud_action == 'edit_from_details')): + host.custom_ident = new_custom_id + + assert host.custom_ident == new_custom_id + assert navigate_to(host, 'Details').entities.summary("Properties").get_text_of( + "Custom Identifier") == new_custom_id + else: + host.delete() + host.delete(cancel=False)