#!/usr/bin/python3## Copyright (C) 2022 Red Hat, Inc.# SPDX-License-Identifier: LGPL-2.1-or-laterfrom anacondalib import VirtInstallMachineCase, pixel_tests_ignorefrom installer import Installerfrom password import Passwordfrom review import Reviewfrom storage import BOOT_PARTITION_DEFAULT_SIZE_GB, Storagefrom testlib import nondestructive, test_main # pylint: disable=import-errorfrom utils import pretend_live_workstation_iso@nondestructiveclass TestReview(VirtInstallMachineCase):def testWorkstation(self):"""Description:Check the review step for a Live ISO installationExpected results:- The review step is shown- The review step shows the correct information- The review step shows the correct information after setting encryption- The hostname is shown for Live ISO- The timezone is not shown for Live ISO"""b = self.browserm = self.machinei = Installer(b, m)s = Storage(b, m)p = Password(b, s.encryption_id_prefix)r = Review(b, m)pretend_live_workstation_iso(self, i, m)i.open()# After clicking 'Next' on the storage step, partitioning is done, thus changing the available space on the disk# Since this is a non-destructive test we need to make sure the we reset partitioning to how it was before the test startedi.reach(i.steps.REVIEW)# check language is shownr.check_language("English (United States)")# check selected disks are shownr.check_disk("vda", "16.1 GB vda (Virtio Block Device)")r.check_disk_row("vda", "/boot", "vda2", BOOT_PARTITION_DEFAULT_SIZE_GB, True, "xfs")r.check_disk_row("vda", "/", "vda3, LVM", "13.3 GB", True, "xfs")# check storage configurationr.check_storage_config("Use entire disk")# check hostname is visible for Live ISO with DHCP defaultr.check_hostname("transient, will use DHCP")# check timezone is not visible for Live ISOr.check_timezone_not_present()# Pixel test the review stepb.assert_pixels("#app","review-step-basic",ignore=pixel_tests_ignore,)i.reach_on_sidebar(i.steps.STORAGE_CONFIGURATION)s.set_encryption_selected(True)strong_password = "Rwce82ybF7dXtCzFumanchu!!!!!!!!"p.set_password(strong_password)p.set_password_confirm(strong_password)i.reach(i.steps.REVIEW)# check selected disks are shownr.check_disk("vda", "16.1 GB vda (Virtio Block Device)")r.check_disk_row("vda", "/boot/efi", "vda1", "629 MB", True, "efi", is_encrypted=False)r.check_disk_row("vda", "/boot", "vda2", BOOT_PARTITION_DEFAULT_SIZE_GB, True, "xfs", is_encrypted=False)r.check_disk_row("vda", "/", "vda3, LVM", "13.3 GB", True, "xfs", is_encrypted=True)# move the mouse away to avoid highlighting any UI element (pixel ref does not expect that)b.mouse("#app", "mouseenter")# Pixel test the review step with encrypted diskb.assert_pixels("#app","review-step-basic-encrypted",ignore=pixel_tests_ignore,)def testHostnameHandling(self):"""Description:Check the hostname handling in the review stepExpected results:- The hostname can be set to empty string- The hostname can be set to a custom value"""b = self.browserm = self.machinei = Installer(b, m)r = Review(b, m)i.open()self.addCleanup(r.dbus_reset_hostname)i.reach(i.steps.REVIEW)# Save hostname in modal - variant for empty hostnameb.click("button:contains('edit')")b.wait_in_text("#system_information_change_hostname", "Set custom hostname")b.set_input_text("#review-handle-hostname-hostname", "Test false", append=False, value_check=False)b.set_input_text("#review-handle-hostname-hostname", "test123.first", append=False, value_check=True)b.click("button:contains('Save')")r.check_hostname("test123.first")# Try to set empty hostname - variant for changing hostnameb.click("button:contains('edit')")b.wait_in_text("#system_information_change_hostname", "Change hostname")b.set_input_text("#review-handle-hostname-hostname", "", append=False, value_check=True)b.click("button:contains('Change')")r.check_hostname("")hostname = r.dbus_get_hostname()self.assertIn('s ""\n', hostname)# Change hostname in modal - variant for changing hostnameb.click("button:contains('edit')")b.wait_in_text("#system_information_change_hostname", "Set custom hostname")b.set_input_text("#review-handle-hostname-hostname", "test123", append=False, value_check=True)b.click("button:contains('Save')")r.check_hostname("test123")hostname = r.dbus_get_hostname()self.assertIn('s "test123"\n', hostname)if __name__ == '__main__':test_main()