From b8712f80c1c310f7c5a635889722e67fb7de5e9b Mon Sep 17 00:00:00 2001 From: PJ Richardson Date: Wed, 11 Dec 2019 18:36:37 -0500 Subject: [PATCH 01/14] Create draft of rewrite of test_infrastructure_hosts_crud to edit only single hosts --- cfme/tests/infrastructure/test_host.py | 80 +++++++++++++++++++++++--- 1 file changed, 71 insertions(+), 9 deletions(-) diff --git a/cfme/tests/infrastructure/test_host.py b/cfme/tests/infrastructure/test_host.py index ef8561d9bb..e7a6e596ff 100644 --- a/cfme/tests/infrastructure/test_host.py +++ b/cfme/tests/infrastructure/test_host.py @@ -10,6 +10,7 @@ from cfme.common.host_views import HostsCompareView from cfme.common.host_views import HostsEditView from cfme.common.host_views import ProviderHostsCompareView +from cfme.common.host_views import HostsEditView, HostEditView, HostsView, HostDetailsView from cfme.common.provider_views import InfraProviderDetailsView from cfme.common.provider_views import InfraProvidersView from cfme.common.provider_views import ProviderNodesView @@ -539,10 +540,10 @@ def test_add_ipmi_refresh(appliance, setup_provider): view = navigate_to(host, "Edit") assert view.ipmi_address.read() == ipmi_address +from datetime import datetime @test_requirements.infra_hosts -@pytest.mark.parametrize("num_hosts", [1, 2, 4]) -@pytest.mark.meta(blockers=[BZ(1634794, forced_streams=["5.10"])], automates=[1634794]) +@pytest.mark.parametrize("num_hosts", [1,]) def test_infrastructure_hosts_crud(appliance, setup_provider_min_hosts, provider, num_hosts): """ Polarion: @@ -552,17 +553,78 @@ def test_infrastructure_hosts_crud(appliance, setup_provider_min_hosts, provider initialEstimate: 1/6h Bugzilla: 1634794 + + Just use multiple asserts. + Can't create, so start edit but nav away, update, cancel update, and delete. ?reset cases? + edit from details page? ****This is where we end up after an edit or cancel? """ + # edit host 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): + hostname = h.name 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. + edit_view = provider.create_view(HostEditView) + stamp = datetime.now() + edit_string = f'Edit host data. {stamp}' + edit_view.custom_ident.fill(edit_string) + edit_view.save_button.click() + # now verify the change is displayed. + host_view = provider.create_view(HostDetailsView) + host_view.flash.assert_success_message(f'Host / Node "{hostname}" was saved') + custom_id = host_view.entities.summary("Properties").get_text_of("Custom Identifier") + assert custom_id == edit_string + # cancel edit host + hosts_view = navigate_to(provider.collections.hosts, "All") + for h in hosts_view.entities.get_all(slice=my_slice): + hostname = h.name + h.ensure_checked() + hosts_view.toolbar.configuration.item_select('Edit Selected items', + handle_alert=False) + edit_view = provider.create_view(HostEditView) + stamp = datetime.now() + cancel_string = f'Edit host data. {stamp}' + edit_view.custom_ident.fill(cancel_string) + edit_view.cancel_button.click() + # now verify the change is displayed. + host_view = provider.create_view(HostDetailsView) + host_view.flash.assert_success_message(f'Edit of Host / Node "{hostname}" was cancelled by ' + f'the user') + custom_id = host_view.entities.summary("Properties").get_text_of("Custom Identifier") + assert custom_id == edit_string + # reset + hosts_view = navigate_to(provider.collections.hosts, "All") + for h in hosts_view.entities.get_all(slice=my_slice): + hostname = h.name + h.ensure_checked() + hosts_view.toolbar.configuration.item_select('Edit Selected items', + handle_alert=False) + edit_view = provider.create_view(HostEditView) + stamp = datetime.now() + reset_string = f'Edit host data. {stamp}' + edit_view.custom_ident.fill(reset_string) + edit_view.reset_button.click() + # TODO check warning flash banner "All changes have been reset" + # update after reset and save + stamp = datetime.now() + reset_edit_string = f'Reset host data. {stamp}' + edit_view.custom_ident.fill(reset_edit_string) + edit_view.save_button.click() + # now verify the change is displayed. + host_view = provider.create_view(HostDetailsView) + host_view.flash.assert_success_message(f'Host / Node "{hostname}" was saved') + custom_id = host_view.entities.summary("Properties").get_text_of("Custom Identifier") + assert custom_id == reset_edit_string + # delete + hosts_view = navigate_to(provider.collections.hosts, "All") + for h in hosts_view.entities.get_all(slice=my_slice): + # note the host name so I can verify the deletion. + h.ensure_checked() + hosts_view.toolbar.configuration.item_select('Remove items from Inventory', + handle_alert=True) + host_view.flash.assert_success_message(f'Delete initiated for 1 Host / Node from the CFME ' + f'Database') + # TODO create and check displayed view. + # TODO verify host is deleted and not shown in view. and number of hosts has decremented. From 3c10cdf1d1a224161ba80a19865d3fe925a95dfa Mon Sep 17 00:00:00 2001 From: PJ Richardson Date: Wed, 11 Dec 2019 19:00:45 -0500 Subject: [PATCH 02/14] Add check for reset flash banner and edit from details view --- cfme/tests/infrastructure/test_host.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/cfme/tests/infrastructure/test_host.py b/cfme/tests/infrastructure/test_host.py index e7a6e596ff..8359100a8d 100644 --- a/cfme/tests/infrastructure/test_host.py +++ b/cfme/tests/infrastructure/test_host.py @@ -558,7 +558,7 @@ def test_infrastructure_hosts_crud(appliance, setup_provider_min_hosts, provider Can't create, so start edit but nav away, update, cancel update, and delete. ?reset cases? edit from details page? ****This is where we end up after an edit or cancel? """ - # edit host + # edit host from provider hosts view 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): @@ -576,6 +576,19 @@ def test_infrastructure_hosts_crud(appliance, setup_provider_min_hosts, provider host_view.flash.assert_success_message(f'Host / Node "{hostname}" was saved') custom_id = host_view.entities.summary("Properties").get_text_of("Custom Identifier") assert custom_id == edit_string + # edit host from host detail view + hosts_view.toolbar.configuration.item_select('Edit This item', + handle_alert=False) + edit_view = provider.create_view(HostEditView) + stamp = datetime.now() + edit_string = f'Edit host data. {stamp}' + edit_view.custom_ident.fill(edit_string) + edit_view.save_button.click() + # now verify the change is displayed. + host_view = provider.create_view(HostDetailsView) + host_view.flash.assert_success_message(f'Host / Node "{hostname}" was saved') + custom_id = host_view.entities.summary("Properties").get_text_of("Custom Identifier") + assert custom_id == edit_string # cancel edit host hosts_view = navigate_to(provider.collections.hosts, "All") for h in hosts_view.entities.get_all(slice=my_slice): @@ -606,7 +619,7 @@ def test_infrastructure_hosts_crud(appliance, setup_provider_min_hosts, provider reset_string = f'Edit host data. {stamp}' edit_view.custom_ident.fill(reset_string) edit_view.reset_button.click() - # TODO check warning flash banner "All changes have been reset" + edit_view.flash.assert_message(f'All changes have been reset') # update after reset and save stamp = datetime.now() reset_edit_string = f'Reset host data. {stamp}' @@ -628,3 +641,4 @@ def test_infrastructure_hosts_crud(appliance, setup_provider_min_hosts, provider f'Database') # TODO create and check displayed view. # TODO verify host is deleted and not shown in view. and number of hosts has decremented. + # TODO add appliance host cases From 116c070ab52a5795eeeadb3db2fc90b55df48c26 Mon Sep 17 00:00:00 2001 From: PJ Richardson Date: Wed, 11 Dec 2019 22:38:04 -0500 Subject: [PATCH 03/14] Clean up comments --- cfme/tests/infrastructure/test_host.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/cfme/tests/infrastructure/test_host.py b/cfme/tests/infrastructure/test_host.py index 8359100a8d..ee43985f95 100644 --- a/cfme/tests/infrastructure/test_host.py +++ b/cfme/tests/infrastructure/test_host.py @@ -553,10 +553,6 @@ def test_infrastructure_hosts_crud(appliance, setup_provider_min_hosts, provider initialEstimate: 1/6h Bugzilla: 1634794 - - Just use multiple asserts. - Can't create, so start edit but nav away, update, cancel update, and delete. ?reset cases? - edit from details page? ****This is where we end up after an edit or cancel? """ # edit host from provider hosts view my_slice = slice(0, num_hosts, None) @@ -577,7 +573,7 @@ def test_infrastructure_hosts_crud(appliance, setup_provider_min_hosts, provider custom_id = host_view.entities.summary("Properties").get_text_of("Custom Identifier") assert custom_id == edit_string # edit host from host detail view - hosts_view.toolbar.configuration.item_select('Edit This item', + hosts_view.toolbar.configuration.item_select('Edit this item', handle_alert=False) edit_view = provider.create_view(HostEditView) stamp = datetime.now() @@ -633,12 +629,10 @@ def test_infrastructure_hosts_crud(appliance, setup_provider_min_hosts, provider # delete hosts_view = navigate_to(provider.collections.hosts, "All") for h in hosts_view.entities.get_all(slice=my_slice): - # note the host name so I can verify the deletion. h.ensure_checked() hosts_view.toolbar.configuration.item_select('Remove items from Inventory', handle_alert=True) - host_view.flash.assert_success_message(f'Delete initiated for 1 Host / Node from the CFME ' + host_view.flash.assert_success_message(f'Delete initiated for 1 Hosts / Nodes from the CFME ' f'Database') - # TODO create and check displayed view. - # TODO verify host is deleted and not shown in view. and number of hosts has decremented. # TODO add appliance host cases + From faa6e17b2876bacb6c49a78fcca54f3160a17028 Mon Sep 17 00:00:00 2001 From: PJ Richardson Date: Wed, 11 Dec 2019 22:46:46 -0500 Subject: [PATCH 04/14] Fix flake8 issues --- cfme/tests/infrastructure/test_host.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cfme/tests/infrastructure/test_host.py b/cfme/tests/infrastructure/test_host.py index ee43985f95..6b9bf9622a 100644 --- a/cfme/tests/infrastructure/test_host.py +++ b/cfme/tests/infrastructure/test_host.py @@ -2,6 +2,7 @@ import socket import pytest +from datetime import datetime from wait_for import TimedOutError from widgetastic.exceptions import UnexpectedAlertPresentException @@ -540,10 +541,9 @@ def test_add_ipmi_refresh(appliance, setup_provider): view = navigate_to(host, "Edit") assert view.ipmi_address.read() == ipmi_address -from datetime import datetime @test_requirements.infra_hosts -@pytest.mark.parametrize("num_hosts", [1,]) +@pytest.mark.parametrize("num_hosts", [1, ]) def test_infrastructure_hosts_crud(appliance, setup_provider_min_hosts, provider, num_hosts): """ Polarion: @@ -635,4 +635,3 @@ def test_infrastructure_hosts_crud(appliance, setup_provider_min_hosts, provider host_view.flash.assert_success_message(f'Delete initiated for 1 Hosts / Nodes from the CFME ' f'Database') # TODO add appliance host cases - From 6226e89ab5f5714ac4735b8bbc2815c21dab7cf7 Mon Sep 17 00:00:00 2001 From: PJ Richardson Date: Wed, 11 Dec 2019 23:46:42 -0500 Subject: [PATCH 05/14] Reorder imports --- cfme/tests/infrastructure/test_host.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cfme/tests/infrastructure/test_host.py b/cfme/tests/infrastructure/test_host.py index 6b9bf9622a..a4e9b6d1d9 100644 --- a/cfme/tests/infrastructure/test_host.py +++ b/cfme/tests/infrastructure/test_host.py @@ -1,17 +1,17 @@ import random import socket +from datetime import datetime import pytest -from datetime import datetime 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 HostDetailsView +from cfme.common.host_views import HostEditView from cfme.common.host_views import HostsCompareView from cfme.common.host_views import HostsEditView -from cfme.common.host_views import ProviderHostsCompareView -from cfme.common.host_views import HostsEditView, HostEditView, HostsView, HostDetailsView from cfme.common.provider_views import InfraProviderDetailsView from cfme.common.provider_views import InfraProvidersView from cfme.common.provider_views import ProviderNodesView From e625b571edbcb7f23f38155689d307998fb27977 Mon Sep 17 00:00:00 2001 From: PJ Richardson Date: Thu, 12 Dec 2019 00:03:55 -0500 Subject: [PATCH 06/14] Removing outdated BZ lable --- cfme/tests/infrastructure/test_host.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/cfme/tests/infrastructure/test_host.py b/cfme/tests/infrastructure/test_host.py index a4e9b6d1d9..3ea7d31328 100644 --- a/cfme/tests/infrastructure/test_host.py +++ b/cfme/tests/infrastructure/test_host.py @@ -551,8 +551,6 @@ def test_infrastructure_hosts_crud(appliance, setup_provider_min_hosts, provider casecomponent: Infra caseimportance: low initialEstimate: 1/6h - Bugzilla: - 1634794 """ # edit host from provider hosts view my_slice = slice(0, num_hosts, None) From 97e722e5f2249a1d96a05a5c2be84401f585fe4f Mon Sep 17 00:00:00 2001 From: PJ Richardson Date: Thu, 23 Jan 2020 14:18:16 -0500 Subject: [PATCH 07/14] Use fauxfactory instead of datetime to generate a unique string for validation --- cfme/tests/infrastructure/test_host.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cfme/tests/infrastructure/test_host.py b/cfme/tests/infrastructure/test_host.py index 3ea7d31328..fc1585c758 100644 --- a/cfme/tests/infrastructure/test_host.py +++ b/cfme/tests/infrastructure/test_host.py @@ -2,6 +2,7 @@ import socket from datetime import datetime +import fauxfactory import pytest from wait_for import TimedOutError from widgetastic.exceptions import UnexpectedAlertPresentException @@ -561,7 +562,7 @@ def test_infrastructure_hosts_crud(appliance, setup_provider_min_hosts, provider hosts_view.toolbar.configuration.item_select('Edit Selected items', handle_alert=False) edit_view = provider.create_view(HostEditView) - stamp = datetime.now() + stamp = fauxfactory.gen_alphanumeric() edit_string = f'Edit host data. {stamp}' edit_view.custom_ident.fill(edit_string) edit_view.save_button.click() From cb2ca37591fe58c3bf90cc009d58fffbff4e6413 Mon Sep 17 00:00:00 2001 From: PJ Richardson Date: Wed, 22 Apr 2020 17:16:27 -0400 Subject: [PATCH 08/14] Add newline before comments and remove remaining usage of datetime --- cfme/tests/infrastructure/test_host.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/cfme/tests/infrastructure/test_host.py b/cfme/tests/infrastructure/test_host.py index fc1585c758..63011c9939 100644 --- a/cfme/tests/infrastructure/test_host.py +++ b/cfme/tests/infrastructure/test_host.py @@ -1,11 +1,9 @@ import random import socket -from datetime import datetime 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 @@ -13,8 +11,8 @@ from cfme.common.host_views import HostEditView 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 @@ -575,7 +573,7 @@ def test_infrastructure_hosts_crud(appliance, setup_provider_min_hosts, provider hosts_view.toolbar.configuration.item_select('Edit this item', handle_alert=False) edit_view = provider.create_view(HostEditView) - stamp = datetime.now() + stamp = fauxfactory.gen_alphanumeric() edit_string = f'Edit host data. {stamp}' edit_view.custom_ident.fill(edit_string) edit_view.save_button.click() @@ -592,7 +590,7 @@ def test_infrastructure_hosts_crud(appliance, setup_provider_min_hosts, provider hosts_view.toolbar.configuration.item_select('Edit Selected items', handle_alert=False) edit_view = provider.create_view(HostEditView) - stamp = datetime.now() + stamp = fauxfactory.gen_alphanumeric() cancel_string = f'Edit host data. {stamp}' edit_view.custom_ident.fill(cancel_string) edit_view.cancel_button.click() @@ -610,13 +608,13 @@ def test_infrastructure_hosts_crud(appliance, setup_provider_min_hosts, provider hosts_view.toolbar.configuration.item_select('Edit Selected items', handle_alert=False) edit_view = provider.create_view(HostEditView) - stamp = datetime.now() + stamp = fauxfactory.gen_alphanumeric() reset_string = f'Edit host data. {stamp}' edit_view.custom_ident.fill(reset_string) edit_view.reset_button.click() edit_view.flash.assert_message(f'All changes have been reset') # update after reset and save - stamp = datetime.now() + stamp = fauxfactory.gen_alphanumeric() reset_edit_string = f'Reset host data. {stamp}' edit_view.custom_ident.fill(reset_edit_string) edit_view.save_button.click() From 9e444611dfdba5391415f69d1e61ada7ed5fb1b3 Mon Sep 17 00:00:00 2001 From: PJ Richardson Date: Thu, 23 Apr 2020 15:56:00 -0400 Subject: [PATCH 09/14] Add from_details kwarg to host.update --- cfme/infrastructure/host.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cfme/infrastructure/host.py b/cfme/infrastructure/host.py index a5cbce0fcd..e7ccd8b9d5 100644 --- a/cfme/infrastructure/host.py +++ b/cfme/infrastructure/host.py @@ -92,14 +92,15 @@ 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") view = navigate_to(self, "Edit") changed = view.fill({ "name": updates.get("name"), From 1255296e46cfb1defe2889f66c22ad92a510dd90 Mon Sep 17 00:00:00 2001 From: PJ Richardson Date: Thu, 23 Apr 2020 16:30:21 -0400 Subject: [PATCH 10/14] Update host.update nav to support edit from hosts view --- cfme/infrastructure/host.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cfme/infrastructure/host.py b/cfme/infrastructure/host.py index e7ccd8b9d5..614f273f4a 100644 --- a/cfme/infrastructure/host.py +++ b/cfme/infrastructure/host.py @@ -101,6 +101,8 @@ def update(self, updates, validate_credentials=False, from_details=False): """ 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"), From 00bdd96fa32fbb4fb22e3ce94a9cb8b0df66044f Mon Sep 17 00:00:00 2001 From: PJ Richardson Date: Thu, 23 Apr 2020 16:34:50 -0400 Subject: [PATCH 11/14] Rewrite test_infrastructure_hosts_crud utilizing parameterization for crud actions --- cfme/tests/infrastructure/test_host.py | 104 +++++-------------------- 1 file changed, 19 insertions(+), 85 deletions(-) diff --git a/cfme/tests/infrastructure/test_host.py b/cfme/tests/infrastructure/test_host.py index 63011c9939..7f15504496 100644 --- a/cfme/tests/infrastructure/test_host.py +++ b/cfme/tests/infrastructure/test_host.py @@ -7,8 +7,6 @@ from cfme import test_requirements from cfme.base.credential import Credential -from cfme.common.host_views import HostDetailsView -from cfme.common.host_views import HostEditView from cfme.common.host_views import HostsCompareView from cfme.common.host_views import HostsEditView from cfme.common.host_views import ProviderHostsCompareView @@ -542,8 +540,8 @@ def test_add_ipmi_refresh(appliance, setup_provider): @test_requirements.infra_hosts -@pytest.mark.parametrize("num_hosts", [1, ]) -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 @@ -551,84 +549,20 @@ def test_infrastructure_hosts_crud(appliance, setup_provider_min_hosts, provider caseimportance: low initialEstimate: 1/6h """ - # edit host from provider hosts view - 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): - hostname = h.name - h.ensure_checked() - hosts_view.toolbar.configuration.item_select('Edit Selected items', - handle_alert=False) - edit_view = provider.create_view(HostEditView) - stamp = fauxfactory.gen_alphanumeric() - edit_string = f'Edit host data. {stamp}' - edit_view.custom_ident.fill(edit_string) - edit_view.save_button.click() - # now verify the change is displayed. - host_view = provider.create_view(HostDetailsView) - host_view.flash.assert_success_message(f'Host / Node "{hostname}" was saved') - custom_id = host_view.entities.summary("Properties").get_text_of("Custom Identifier") - assert custom_id == edit_string - # edit host from host detail view - hosts_view.toolbar.configuration.item_select('Edit this item', - handle_alert=False) - edit_view = provider.create_view(HostEditView) - stamp = fauxfactory.gen_alphanumeric() - edit_string = f'Edit host data. {stamp}' - edit_view.custom_ident.fill(edit_string) - edit_view.save_button.click() - # now verify the change is displayed. - host_view = provider.create_view(HostDetailsView) - host_view.flash.assert_success_message(f'Host / Node "{hostname}" was saved') - custom_id = host_view.entities.summary("Properties").get_text_of("Custom Identifier") - assert custom_id == edit_string - # cancel edit host - hosts_view = navigate_to(provider.collections.hosts, "All") - for h in hosts_view.entities.get_all(slice=my_slice): - hostname = h.name - h.ensure_checked() - hosts_view.toolbar.configuration.item_select('Edit Selected items', - handle_alert=False) - edit_view = provider.create_view(HostEditView) - stamp = fauxfactory.gen_alphanumeric() - cancel_string = f'Edit host data. {stamp}' - edit_view.custom_ident.fill(cancel_string) - edit_view.cancel_button.click() - # now verify the change is displayed. - host_view = provider.create_view(HostDetailsView) - host_view.flash.assert_success_message(f'Edit of Host / Node "{hostname}" was cancelled by ' - f'the user') - custom_id = host_view.entities.summary("Properties").get_text_of("Custom Identifier") - assert custom_id == edit_string - # reset - hosts_view = navigate_to(provider.collections.hosts, "All") - for h in hosts_view.entities.get_all(slice=my_slice): - hostname = h.name - h.ensure_checked() - hosts_view.toolbar.configuration.item_select('Edit Selected items', - handle_alert=False) - edit_view = provider.create_view(HostEditView) - stamp = fauxfactory.gen_alphanumeric() - reset_string = f'Edit host data. {stamp}' - edit_view.custom_ident.fill(reset_string) - edit_view.reset_button.click() - edit_view.flash.assert_message(f'All changes have been reset') - # update after reset and save - stamp = fauxfactory.gen_alphanumeric() - reset_edit_string = f'Reset host data. {stamp}' - edit_view.custom_ident.fill(reset_edit_string) - edit_view.save_button.click() - # now verify the change is displayed. - host_view = provider.create_view(HostDetailsView) - host_view.flash.assert_success_message(f'Host / Node "{hostname}" was saved') - custom_id = host_view.entities.summary("Properties").get_text_of("Custom Identifier") - assert custom_id == reset_edit_string - # delete - 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('Remove items from Inventory', - handle_alert=True) - host_view.flash.assert_success_message(f'Delete initiated for 1 Hosts / Nodes from the CFME ' - f'Database') - # TODO add appliance host cases + from cfme.utils.update import update + + 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 + assert navigate_to(host, 'Details').entities.summary("Properties").get_text_of( + "Custom Identifier") == new_custom_id + else: + host.delete() + host.delete(cancel=False) From a23d7e2b0425795530e3cc3e088cfa2fe2ef5d0b Mon Sep 17 00:00:00 2001 From: PJ Richardson Date: Fri, 1 May 2020 13:14:05 -0400 Subject: [PATCH 12/14] Add cancel_button and is_displayed to host edit view --- cfme/common/host_views.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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): From 836eebbe30ec99b4f5c256627864729d69aaff88 Mon Sep 17 00:00:00 2001 From: PJ Richardson Date: Fri, 1 May 2020 13:24:32 -0400 Subject: [PATCH 13/14] Update Host.update to support edit from hosts view --- cfme/infrastructure/host.py | 8 +++++--- cfme/tests/infrastructure/test_host.py | 5 +---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cfme/infrastructure/host.py b/cfme/infrastructure/host.py index 614f273f4a..94b4535d82 100644 --- a/cfme/infrastructure/host.py +++ b/cfme/infrastructure/host.py @@ -92,7 +92,7 @@ def __init__(self, **kwargs): super(Host.Credential, self).__init__(**kwargs) self.ipmi = kwargs.get('ipmi') - def update(self, updates, validate_credentials=False, from_details=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. @@ -100,10 +100,12 @@ def update(self, updates, validate_credentials=False, from_details=False): updates (dict): fields that are changing. """ if from_details: - view = navigate_to(self, "Details") + view = navigate_to(self, "Edit") else: view = navigate_to(self.parent, "All") - view = navigate_to(self, "Edit") + 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) 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 7f15504496..f1caf68c7f 100644 --- a/cfme/tests/infrastructure/test_host.py +++ b/cfme/tests/infrastructure/test_host.py @@ -541,7 +541,7 @@ def test_add_ipmi_refresh(appliance, setup_provider): @test_requirements.infra_hosts @pytest.mark.parametrize("crud_action", ['edit_from_hosts', 'edit_from_details', 'remove']) -def test_infrastructure_hosts_crud(appliance, setup_provider, provider, crud_action): +def test_infrastructure_hosts_crud(appliance, setup_provider, crud_action): """ Polarion: assignee: prichard @@ -549,14 +549,11 @@ def test_infrastructure_hosts_crud(appliance, setup_provider, provider, crud_act caseimportance: low initialEstimate: 1/6h """ - from cfme.utils.update import update - 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 From f9dc67f9f8c66b35c3f4e561df8849122247b1d3 Mon Sep 17 00:00:00 2001 From: PJ Richardson Date: Fri, 1 May 2020 14:37:39 -0400 Subject: [PATCH 14/14] Put view.is_displayed back into Host.update() --- cfme/infrastructure/host.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cfme/infrastructure/host.py b/cfme/infrastructure/host.py index 94b4535d82..80d4ec56b3 100644 --- a/cfme/infrastructure/host.py +++ b/cfme/infrastructure/host.py @@ -106,6 +106,7 @@ def update(self, updates, validate_credentials=False, from_details=True): 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"),