ikiwiki: Convert functional tests to non-BDD python format

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
James Valleroy 2021-09-25 09:17:19 -04:00 committed by Sunil Mohan Adapa
parent 19fb965237
commit 73dac73808
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
2 changed files with 27 additions and 39 deletions

View File

@ -1,28 +0,0 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
@apps @ikiwiki
Feature: ikiwiki Wiki and Blog
Manage wikis and blogs.
Background:
Given I'm a logged in user
Given the ikiwiki application is installed
Scenario: Enable ikiwiki application
Given the ikiwiki application is disabled
When I enable the ikiwiki application
Then the ikiwiki site should be available
@backups
Scenario: Backup and restore ikiwiki
Given the ikiwiki application is enabled
When there is an ikiwiki wiki
And I create a backup of the ikiwiki app data with name test_ikiwiki
And I delete the ikiwiki wiki
And I restore the ikiwiki app data backup with name test_ikiwiki
Then the ikiwiki wiki should be restored
Scenario: Disable ikiwiki application
Given the ikiwiki application is enabled
When I disable the ikiwiki application
Then the ikiwiki site should not be available

View File

@ -3,25 +3,41 @@
Functional, browser based tests for ikiwiki app.
"""
from pytest_bdd import scenarios, then, when
import pytest
from plinth.tests import functional
scenarios('ikiwiki.feature')
pytestmark = [pytest.mark.apps, pytest.mark.ikiwiki]
@when('there is an ikiwiki wiki')
def ikiwiki_create_wiki_if_needed(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, 'ikiwiki')
yield
functional.app_disable(session_browser, 'ikiwiki')
def test_enable_disable(session_browser):
"""Test enabling the app."""
functional.app_disable(session_browser, 'ikiwiki')
functional.app_enable(session_browser, 'ikiwiki')
assert functional.is_available(session_browser, 'ikiwiki')
functional.app_disable(session_browser, 'ikiwiki')
assert not functional.is_available(session_browser, 'ikiwiki')
@pytest.mark.backups
def test_backup_and_restore(session_browser):
functional.app_enable(session_browser, 'ikiwiki')
_create_wiki_if_needed(session_browser)
functional.backup_create(session_browser, 'ikiwiki', 'test_ikiwiki')
@when('I delete the ikiwiki wiki')
def ikiwiki_delete_wiki(session_browser):
_delete_wiki(session_browser)
functional.backup_restore(session_browser, 'ikiwiki', 'test_ikiwiki')
@then('the ikiwiki wiki should be restored')
def ikiwiki_should_exist(session_browser):
assert _wiki_exists(session_browser)