mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-11 09:04:54 +00:00
radicale: Convert functional tests to non-BDD python format
Signed-off-by: James Valleroy <jvalleroy@mailbox.org> [sunil: Set an initial value before testing for access rights] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
8daa9aa49d
commit
c120411846
@ -1,54 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
@apps @radicale
|
||||
Feature: Radicale Calendar and Addressbook
|
||||
Configure CalDAV/CardDAV server.
|
||||
|
||||
Background:
|
||||
Given I'm a logged in user
|
||||
Given the radicale application is installed
|
||||
|
||||
Scenario: Enable radicale application
|
||||
Given the radicale application is disabled
|
||||
When I enable the radicale application
|
||||
Then the radicale service should be running
|
||||
And the calendar should be available
|
||||
And the addressbook should be available
|
||||
|
||||
Scenario: Owner-only access rights
|
||||
Given the radicale application is enabled
|
||||
And the access rights are set to "any user can view, but only the owner can make changes"
|
||||
When I change the access rights to "only the owner can view or make changes"
|
||||
Then the radicale service should be running
|
||||
And the access rights should be "only the owner can view or make changes"
|
||||
|
||||
Scenario: Owner-write access rights
|
||||
Given the radicale application is enabled
|
||||
And the access rights are set to "only the owner can view or make changes"
|
||||
When I change the access rights to "any user can view, but only the owner can make changes"
|
||||
Then the radicale service should be running
|
||||
And the access rights should be "any user can view, but only the owner can make changes"
|
||||
|
||||
Scenario: Authenticated access rights
|
||||
Given the radicale application is enabled
|
||||
And the access rights are set to "only the owner can view or make changes"
|
||||
When I change the access rights to "any user can view or make changes"
|
||||
Then the radicale service should be running
|
||||
And the access rights should be "any user can view or make changes"
|
||||
|
||||
@backups
|
||||
Scenario: Backup and restore radicale
|
||||
Given the radicale application is enabled
|
||||
And the access rights are set to "only the owner can view or make changes"
|
||||
When I create a backup of the radicale app data with name test_radicale
|
||||
And I change the access rights to "any user can view, but only the owner can make changes"
|
||||
And I restore the radicale app data backup with name test_radicale
|
||||
Then the radicale service should be running
|
||||
And the access rights should be "only the owner can view or make changes"
|
||||
|
||||
Scenario: Disable radicale application
|
||||
Given the radicale application is enabled
|
||||
When I disable the radicale application
|
||||
Then the radicale service should not be running
|
||||
And the calendar should not be available
|
||||
And the addressbook should not be available
|
||||
@ -5,83 +5,73 @@ Functional, browser based tests for radicale app.
|
||||
|
||||
import logging
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
from pytest_bdd import given, scenarios, then, when
|
||||
|
||||
from plinth.tests import functional
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
scenarios('radicale.feature')
|
||||
|
||||
pytestmark = [pytest.mark.apps, pytest.mark.radicale]
|
||||
|
||||
|
||||
@given('the access rights are set to "only the owner can view or make changes"'
|
||||
)
|
||||
def radicale_given_owner_only(session_browser):
|
||||
@pytest.fixture(scope='module', autouse=True)
|
||||
def fixture_background(session_browser):
|
||||
"""Login and install the app."""
|
||||
functional.login(session_browser)
|
||||
functional.install(session_browser, 'radicale')
|
||||
yield
|
||||
functional.app_disable(session_browser, 'radicale')
|
||||
|
||||
|
||||
def test_enable_disable(session_browser):
|
||||
"""Test enabling the app."""
|
||||
functional.app_disable(session_browser, 'radicale')
|
||||
|
||||
functional.app_enable(session_browser, 'radicale')
|
||||
assert functional.service_is_running(session_browser, 'radicale')
|
||||
assert _calendar_is_available(session_browser)
|
||||
assert _addressbook_is_available(session_browser)
|
||||
|
||||
functional.app_disable(session_browser, 'radicale')
|
||||
assert functional.service_is_not_running(session_browser, 'radicale')
|
||||
assert not _calendar_is_available(session_browser)
|
||||
assert not _addressbook_is_available(session_browser)
|
||||
|
||||
|
||||
def test_access_rights(session_browser):
|
||||
"""Test setting the access rights."""
|
||||
functional.app_enable(session_browser, 'radicale')
|
||||
_set_access_rights(session_browser, 'owner_only')
|
||||
|
||||
|
||||
@given('the access rights are set to "any user can view, but only the '
|
||||
'owner can make changes"')
|
||||
def radicale_given_owner_write(session_browser):
|
||||
# Owner-write access rights
|
||||
_set_access_rights(session_browser, 'owner_write')
|
||||
assert functional.service_is_running(session_browser, 'radicale')
|
||||
assert _get_access_rights(session_browser) == 'owner_write'
|
||||
|
||||
|
||||
@given('the access rights are set to "any user can view or make changes"')
|
||||
def radicale_given_authenticated(session_browser):
|
||||
# Authenticated access rights
|
||||
_set_access_rights(session_browser, 'authenticated')
|
||||
assert functional.service_is_running(session_browser, 'radicale')
|
||||
assert _get_access_rights(session_browser) == 'authenticated'
|
||||
|
||||
|
||||
@when('I change the access rights to "only the owner can view or make changes"'
|
||||
)
|
||||
def radicale_set_owner_only(session_browser):
|
||||
# Owner-only access rights
|
||||
_set_access_rights(session_browser, 'owner_only')
|
||||
|
||||
|
||||
@when('I change the access rights to "any user can view, but only the '
|
||||
'owner can make changes"')
|
||||
def radicale_set_owner_write(session_browser):
|
||||
_set_access_rights(session_browser, 'owner_write')
|
||||
|
||||
|
||||
@when('I change the access rights to "any user can view or make changes"')
|
||||
def radicale_set_authenticated(session_browser):
|
||||
_set_access_rights(session_browser, 'authenticated')
|
||||
|
||||
|
||||
@then('the access rights should be "only the owner can view or make changes"')
|
||||
def radicale_check_owner_only(session_browser):
|
||||
assert functional.service_is_running(session_browser, 'radicale')
|
||||
assert _get_access_rights(session_browser) == 'owner_only'
|
||||
|
||||
|
||||
@then('the access rights should be "any user can view, but only the '
|
||||
'owner can make changes"')
|
||||
def radicale_check_owner_write(session_browser):
|
||||
assert _get_access_rights(session_browser) == 'owner_write'
|
||||
@pytest.mark.backups
|
||||
def test_backup_restore(session_browser):
|
||||
"""Test backup and restore of configuration."""
|
||||
functional.app_enable(session_browser, 'radicale')
|
||||
_set_access_rights(session_browser, 'owner_only')
|
||||
functional.backup_create(session_browser, 'radicale', 'test_radicale')
|
||||
|
||||
_set_access_rights(session_browser, 'owner_write')
|
||||
functional.backup_restore(session_browser, 'radicale', 'test_radicale')
|
||||
|
||||
@then('the access rights should be "any user can view or make changes"')
|
||||
def radicale_check_authenticated(session_browser):
|
||||
assert _get_access_rights(session_browser) == 'authenticated'
|
||||
|
||||
|
||||
@then('the calendar should be available')
|
||||
def assert_calendar_is_available(session_browser):
|
||||
assert _calendar_is_available(session_browser)
|
||||
|
||||
|
||||
@then('the calendar should not be available')
|
||||
def assert_calendar_is_not_available(session_browser):
|
||||
assert not _calendar_is_available(session_browser)
|
||||
|
||||
|
||||
@then('the addressbook should be available')
|
||||
def assert_addressbook_is_available(session_browser):
|
||||
assert _addressbook_is_available(session_browser)
|
||||
|
||||
|
||||
@then('the addressbook should not be available')
|
||||
def assert_addressbook_is_not_available(session_browser):
|
||||
assert not _addressbook_is_available(session_browser)
|
||||
assert functional.service_is_running(session_browser, 'radicale')
|
||||
assert _get_access_rights(session_browser) == 'owner_only'
|
||||
|
||||
|
||||
def _get_access_rights(browser):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user