upgrades: Add functional tests

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Joseph Nuthalapati 2018-10-23 16:23:09 -07:00 committed by James Valleroy
parent 47faa5512d
commit 37d84c0f50
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
4 changed files with 72 additions and 1 deletions

View File

@ -20,7 +20,6 @@ Configures or runs unattended-upgrades
"""
import argparse
import os
import re
import subprocess
import sys

View File

@ -0,0 +1,33 @@
#
# This file is part of FreedomBox.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
@essential @upgrades @system
Feature: Software Upgrades
Configure automatic software upgrades
Background:
Given I'm a logged in user
Scenario: Enable automatic upgrades
Given automatic upgrades are disabled
When I enable automatic upgrades
Then automatic upgrades should be enabled
Scenario: Disable automatic upgrades
Given automatic upgrades are enabled
When I disable automatic upgrades
Then automatic upgrades should be disabled

View File

@ -277,3 +277,21 @@ def security_enable_restricted_logins(browser, enable):
def security_assert_restricted_logins(browser, enabled):
enabled = (enabled == 'enabled')
assert system.security_get_restricted_logins(browser) == enabled
@given(parsers.parse('automatic upgrades are {enabled:w}'))
def upgrades_given_enable_automatic(browser, enabled):
should_enable = (enabled == 'enabled')
system.upgrades_enable_automatic(browser, should_enable)
@when(parsers.parse('I {enable:w} automatic upgrades'))
def upgrades_enable_automatic(browser, enable):
should_enable = (enable == 'enable')
system.upgrades_enable_automatic(browser, should_enable)
@then(parsers.parse('automatic upgrades should be {enabled:w}'))
def upgrades_assert_automatic(browser, enabled):
should_be_enabled = (enabled == 'enabled')
assert system.upgrades_get_automatic(browser) == should_be_enabled

View File

@ -308,3 +308,24 @@ def security_get_restricted_logins(browser):
"""Return whether restricted console logins is enabled."""
nav_to_module(browser, 'security')
return browser.find_by_name('security-restricted_access').first.checked
def upgrades_enable_automatic(browser, should_enable):
"""Enable/disable automatic software upgrades."""
nav_to_module(browser, 'upgrades')
checkbox_element = browser.find_by_name('auto_upgrades_enabled').first
if should_enable == checkbox_element.checked:
return
if should_enable:
checkbox_element.check()
else:
checkbox_element.uncheck()
submit(browser)
def upgrades_get_automatic(browser):
"""Return whether automatic software upgrades is enabled."""
nav_to_module(browser, 'upgrades')
return browser.find_by_name('auto_upgrades_enabled').first.checked