FreedomBox/plinth/modules/privacy/tests/test_functional.py
nbenedek 7e2ebcb743
privacy: Add new system app for popularity-contest
- Keep the description about app generic

- Remove enable/disable option

- Create a booleanfield to turn on/off popcon

- Don't re-enable popcon during an update

Tests:

- When enabling/disabling the option, the `"PARTICIPATE"` value in
`/etc/popularity-contest.conf` is changed to yes/no as expected. For reference
see `/var/lib/dpkg/info/popularity-contest.templates`

- When popcon option is enabled, running sudo sh -x
/etc/cron.daily/popularity-context shows that execution was successful and data
was submitted. Remove files /var/log/popularity-contest* and
/var/lib/popularity-contest/lastsub if necessary. Gpg is used and encrypted data
is what was submitted.

- When popcon option is disabled, running sudo sh -x
/etc/cron.daily/popularity-context shows that execution stopped because the
option is disabled.

Signed-off-by: nbenedek <contact@nbenedek.me>
[sunil: Add a notification to tell users about privacy app]
[sunil: Correct the URL to /sys]
[sunil: Minor code styling changes and updates to description, icon]
[sunil: Ensure that popcon works with encryption]
[sunil: Write configuration to a separate file]
[sunil: Use Shellvars lens instead of Php lns]
[sunil: Add functional tests]
[sunil: Backup/restore the configuration file]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2022-10-10 17:35:26 -07:00

60 lines
2.5 KiB
Python

# SPDX-License-Identifier: AGPL-3.0-or-later
"""Functional, browser based tests for privacy app."""
import pytest
from plinth.tests import functional
pytestmark = [pytest.mark.system, pytest.mark.privacy]
class TestPrivacyApp(functional.BaseAppTests):
"""Tests for privacy app."""
app_name = 'privacy'
has_service = False
has_web = False
disable_after_tests = False
@pytest.fixture(autouse=True)
def fixture_background(self, session_browser):
"""Login, install, and enable the app."""
functional.login(session_browser)
functional.nav_to_module(session_browser, self.app_name)
yield
def test_enable_disable(self, session_browser):
"""Skip test for enabling and disabling the app."""
pytest.skip('Can not be disabled')
@pytest.mark.backups
def test_enable_disable_popcon(self, session_browser):
"""Test that popcon can be enable/disabled."""
functional.change_checkbox_status(session_browser, self.app_name,
'id_enable_popcon', 'disabled')
functional.change_checkbox_status(session_browser, self.app_name,
'id_enable_popcon', 'enabled')
assert session_browser.find_by_id('id_enable_popcon').checked
functional.change_checkbox_status(session_browser, self.app_name,
'id_enable_popcon', 'disabled')
assert not session_browser.find_by_id('id_enable_popcon').checked
@pytest.mark.backups
def test_backup_restore(self, session_browser):
"""Test that backup and restore operations work on the app."""
functional.change_checkbox_status(session_browser, self.app_name,
'id_enable_popcon', 'disabled')
functional.backup_create(session_browser, self.app_name,
'test_' + self.app_name)
functional.nav_to_module(session_browser, self.app_name)
functional.change_checkbox_status(session_browser, self.app_name,
'id_enable_popcon', 'enabled')
functional.backup_restore(session_browser, self.app_name,
'test_' + self.app_name)
functional.nav_to_module(session_browser, self.app_name)
assert not session_browser.find_by_id('id_enable_popcon').checked
def test_uninstall(self, session_browser):
"""Skip test for uninstall."""
pytest.skip('Essential app')