mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-28 08:03:36 +00:00
Closes: #2194. In the four cases fixed, if a notification is present with a 'btn-primary' in it, then instead of submitting the intended form, the button on the notification is clicked. This will result in an indefinite wait for the form to perform an action. Fix this by specifying which form exactly we want to submit. Tests: - Run functional tests for config app and updates app. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
62 lines
1.8 KiB
Python
62 lines
1.8 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""
|
|
Functional, browser based tests for upgrades app.
|
|
"""
|
|
|
|
import pytest
|
|
|
|
from plinth.tests import functional
|
|
|
|
pytestmark = [pytest.mark.system, pytest.mark.essential, pytest.mark.upgrades]
|
|
|
|
|
|
@pytest.fixture(scope='module', autouse=True)
|
|
def fixture_background(session_browser):
|
|
"""Login."""
|
|
functional.login(session_browser)
|
|
yield
|
|
_enable_automatic(session_browser, False)
|
|
|
|
|
|
def test_enable_automatic_upgrades(session_browser):
|
|
"""Test enabling automatic upgrades."""
|
|
_enable_automatic(session_browser, False)
|
|
_enable_automatic(session_browser, True)
|
|
assert _get_automatic(session_browser)
|
|
|
|
_enable_automatic(session_browser, False)
|
|
assert not _get_automatic(session_browser)
|
|
|
|
|
|
@pytest.mark.backups
|
|
def test_backup_restore(session_browser):
|
|
"""Test backup and restore of configuration."""
|
|
_enable_automatic(session_browser, True)
|
|
functional.backup_create(session_browser, 'upgrades', 'test_upgrades')
|
|
|
|
_enable_automatic(session_browser, False)
|
|
functional.backup_restore(session_browser, 'upgrades', 'test_upgrades')
|
|
|
|
assert _get_automatic(session_browser)
|
|
|
|
|
|
def _enable_automatic(browser, should_enable):
|
|
"""Enable/disable automatic software upgrades."""
|
|
functional.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()
|
|
|
|
functional.submit(browser, form_class='form-configuration')
|
|
|
|
|
|
def _get_automatic(browser):
|
|
"""Return whether automatic software upgrades is enabled."""
|
|
functional.nav_to_module(browser, 'upgrades')
|
|
return browser.find_by_name('auto_upgrades_enabled').first.checked
|