1
0
mirror of https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git synced 2024-12-11 05:43:11 +00:00
os-autoinst-distri-fedora/tests/applications/software/repositories.pm

110 lines
4.1 KiB
Perl
Raw Normal View History

use base "installedtest";
use strict;
use testapi;
use utils;
use desktoptools;
# This script checks that the Software repositories can be shown
# and toggled in Software.
# This subroutine does the repository switching.
sub toggle_repo_status {
# The $status identifies the status we want to end up with.
my ($repository, $status) = @_;
# If the $status differ from the current status quo, then
# we need to do the actually toggle.
unless (check_screen("software_repo_$repository-$status")) {
# Click on the $needle to toggle the repository
assert_and_click($repository);
# If we want to switch the repository to "off", then a dialogue appears that asks us
# to confirm that we want to disable the repository. Let's click on the disable button.
if ($status eq "off") {
assert_and_click("software_repo_disable");
}
# Toggling a repo is an administrative task that needs permissions. When no permission
# has been obtained prior to this operation, an authentication dialogue appears
# and we need to provide the user password to enable the operation.
if (check_screen("auth_required", timeout => 10)) {
type_safely(get_var('USER_PASSWORD') || "weakpassword");
send_key("ret");
# Wait for the screen to get still.
wait_still_screen(3);
}
}
# Now, let us check that the repository was successfully toggled by
# comparing the repository status against the off needle.
# If this time, the statuses still don't match, let's die with a message,
# as it seems that the repository cannot be toggled.
# However, sometimes it takes a little time before the toggle button
# reacts, so wait a bit to give it some time.
wait_still_screen(10);
# Check the repo status or die
if (check_screen("software_repo_$repository-$status")) {
die("The repository status does not match the expected situation.");
}
}
sub run {
my $self = shift;
# Sometimes, Software crashes after the VM has been rolled back.
# If so, restart the application.
unless (check_screen("apps_run_software")) {
restart_application("software");
}
# Open the menu
assert_and_click("gnome_burger_menu");
wait_still_screen(2);
# Open the Repositories overview
assert_and_click("software_menu_repositories");
# Check that Repositories are shown
assert_screen("software_repositories");
wait_still_screen(5);
# Find the Fedora Test Updates repository, switch to the switcher button
# and toggle the repo to ON.
send_key_until_needlematch("software_repo_test_updates", 'tab');
toggle_repo_status("software_repo_test_updates", "on");
# Find Fedora Modular repository, switch to the switcher button
# and toggle the repo to OFF.
send_key_until_needlematch("software_repo_fedora_modular", 'tab');
toggle_repo_status("software_repo_fedora_modular", "off");
# Switch to the root console to check if the repositories were
# correctly switched off and on.
$self->root_console(tty => 3);
# Check that updates testing is switched on.
# Mind that the script_run returns the exit code, which is interpreted by Perl
# in an opposite way, therefore if the exit code is 1, we expect True in Perl.
if (script_run("dnf repolist | grep updates-testing")) {
die("The updates testing repository is not switched on, but should be.");
}
# On Rawhide, the installation actually includes the fedora-modular
# as well as the rawhide-modular repository and the one that gets
# switched off is the rawhide-modular. Therefore, we need to distinguish
# according to the version.
my $version = "fedora";
if (get_var('VERSION') eq "Rawhide") {
$version = "rawhide";
diag("VERSION: $version");
}
script_run("dnf repolist");
unless (script_run("dnf repolist | grep $version-modular")) {
die("The Modular repository is not switched off, but should be.");
}
}
sub test_flags {
# When finished, rollback to milestone.
return {always_rollback => 1};
}
1;
# vim: set sw=4 et: