diff --git a/plinth/modules/mldonkey/tests/mldonkey.feature b/plinth/modules/mldonkey/tests/mldonkey.feature deleted file mode 100644 index ea4f95b13..000000000 --- a/plinth/modules/mldonkey/tests/mldonkey.feature +++ /dev/null @@ -1,38 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later - -@apps @mldonkey @sso -Feature: MLDonkey eDonkey Network Client - Run the eDonkey Network client. - -Background: - Given I'm a logged in user - Given the mldonkey application is installed - -Scenario: Enable mldonkey application - Given the mldonkey application is disabled - When I enable the mldonkey application - Then the mldonkey service should be running - Then the mldonkey site should be available - -Scenario: Upload an ed2k file to mldonkey - Given the mldonkey application is enabled - When all ed2k files are removed from mldonkey - And I upload a sample ed2k file to mldonkey - Then there should be 1 ed2k files listed in mldonkey - -@backups -Scenario: Backup and restore mldonkey - Given the mldonkey application is enabled - When all ed2k files are removed from mldonkey - And I upload a sample ed2k file to mldonkey - And I create a backup of the mldonkey app data with name test_mldonkey - And all ed2k files are removed from mldonkey - And I restore the mldonkey app data backup with name test_mldonkey - Then the mldonkey service should be running - And there should be 1 ed2k files listed in mldonkey - -Scenario: Disable mldonkey application - Given the mldonkey application is enabled - When I disable the mldonkey application - Then the mldonkey service should not be running - Then the mldonkey site should not be available diff --git a/plinth/modules/mldonkey/tests/test_functional.py b/plinth/modules/mldonkey/tests/test_functional.py index 6306e88ef..c6fe54db8 100644 --- a/plinth/modules/mldonkey/tests/test_functional.py +++ b/plinth/modules/mldonkey/tests/test_functional.py @@ -3,28 +3,54 @@ Functional, browser based tests for mldonkey app. """ -from pytest_bdd import parsers, scenarios, then, when - +import pytest from plinth.tests import functional -scenarios('mldonkey.feature') +pytestmark = [pytest.mark.apps, pytest.mark.mldonkey] -@when('all ed2k files are removed from mldonkey') -def mldonkey_remove_all_ed2k_files(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, 'mldonkey') + yield + functional.app_disable(session_browser, 'mldonkey') + + +def test_enable_disable(session_browser): + """Test enabling the app.""" + functional.app_disable(session_browser, 'mldonkey') + + functional.app_enable(session_browser, 'mldonkey') + assert functional.service_is_running(session_browser, 'mldonkey') + assert functional.is_available(session_browser, 'mldonkey') + + functional.app_disable(session_browser, 'mldonkey') + assert functional.service_is_not_running(session_browser, 'mldonkey') + assert not functional.is_available(session_browser, 'mldonkey') + + +def test_upload(session_browser): + """Test uploading an ed2k file to mldonkey.""" + functional.app_enable(session_browser, 'mldonkey') _remove_all_ed2k_files(session_browser) - - -@when('I upload a sample ed2k file to mldonkey') -def mldonkey_upload_sample_ed2k_file(session_browser): _upload_sample_ed2k_file(session_browser) + assert _get_number_of_ed2k_files(session_browser) == 1 -@then( - parsers.parse( - 'there should be {ed2k_files_number:d} ed2k files listed in mldonkey')) -def mldonkey_assert_number_of_ed2k_files(session_browser, ed2k_files_number): - assert ed2k_files_number == _get_number_of_ed2k_files(session_browser) +def test_backup_restore(session_browser): + """Test backup and restore of ed2k files.""" + functional.app_enable(session_browser, 'mldonkey') + _remove_all_ed2k_files(session_browser) + _upload_sample_ed2k_file(session_browser) + functional.backup_create(session_browser, 'mldonkey', 'test_mldonkey') + + _remove_all_ed2k_files(session_browser) + functional.backup_restore(session_browser, 'mldonkey', 'test_mldonkey') + + assert functional.service_is_running(session_browser, 'mldonkey') + assert _get_number_of_ed2k_files(session_browser) == 1 def _submit_command(browser, command):