mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-11 09:04:54 +00:00
transmission: 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:
parent
1bc42a7647
commit
79f09e3d88
@ -5,27 +5,58 @@ Functional, browser based tests for transmission app.
|
||||
|
||||
import os
|
||||
|
||||
from pytest_bdd import parsers, scenarios, then, when
|
||||
|
||||
import pytest
|
||||
from plinth.tests import functional
|
||||
|
||||
scenarios('transmission.feature')
|
||||
pytestmark = [pytest.mark.apps, pytest.mark.transmission, pytest.mark.sso]
|
||||
|
||||
|
||||
@when('all torrents are removed from transmission')
|
||||
def transmission_remove_all_torrents(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, 'transmission')
|
||||
yield
|
||||
functional.app_disable(session_browser, 'transmission')
|
||||
|
||||
|
||||
def test_enable_disable(session_browser):
|
||||
"""Test enabling the app."""
|
||||
functional.app_disable(session_browser, 'transmission')
|
||||
|
||||
functional.app_enable(session_browser, 'transmission')
|
||||
assert functional.is_available(session_browser, 'transmission')
|
||||
|
||||
functional.app_disable(session_browser, 'transmission')
|
||||
assert not functional.is_available(session_browser, 'transmission')
|
||||
|
||||
|
||||
def test_upload_torrent(session_browser):
|
||||
"""Test uploading a torrent to Transmission."""
|
||||
functional.app_enable(session_browser, 'transmission')
|
||||
_remove_all_torrents(session_browser)
|
||||
|
||||
|
||||
@when('I upload a sample torrent to transmission')
|
||||
def transmission_upload_sample_torrent(session_browser):
|
||||
_upload_sample_torrent(session_browser)
|
||||
_assert_number_of_torrents(session_browser, 1)
|
||||
|
||||
|
||||
@then(
|
||||
parsers.parse(
|
||||
'there should be {torrents_number:d} torrents listed in transmission'))
|
||||
def transmission_assert_number_of_torrents(session_browser, torrents_number):
|
||||
@pytest.mark.backups
|
||||
def test_backup_restore(session_browser):
|
||||
"""Test backup and restore of app data."""
|
||||
functional.app_enable(session_browser, 'transmission')
|
||||
_remove_all_torrents(session_browser)
|
||||
_upload_sample_torrent(session_browser)
|
||||
functional.backup_create(session_browser, 'transmission',
|
||||
'test_transmission')
|
||||
|
||||
_remove_all_torrents(session_browser)
|
||||
functional.backup_restore(session_browser, 'transmission',
|
||||
'test_transmission')
|
||||
|
||||
assert functional.service_is_running(session_browser, 'transmission')
|
||||
_assert_number_of_torrents(session_browser, 1)
|
||||
|
||||
|
||||
def _assert_number_of_torrents(session_browser, torrents_number):
|
||||
functional.visit(session_browser, '/transmission')
|
||||
assert functional.eventually(
|
||||
lambda: torrents_number == _get_number_of_torrents(session_browser))
|
||||
|
||||
@ -1,36 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
@apps @transmission @sso
|
||||
Feature: Transmission BitTorrent Client
|
||||
Run the Transmission BitTorrent client.
|
||||
|
||||
Background:
|
||||
Given I'm a logged in user
|
||||
Given the transmission application is installed
|
||||
|
||||
Scenario: Enable transmission application
|
||||
Given the transmission application is disabled
|
||||
When I enable the transmission application
|
||||
Then the transmission site should be available
|
||||
|
||||
Scenario: Upload a torrent to transmission
|
||||
Given the transmission application is enabled
|
||||
When all torrents are removed from transmission
|
||||
And I upload a sample torrent to transmission
|
||||
Then there should be 1 torrents listed in transmission
|
||||
|
||||
@backups
|
||||
Scenario: Backup and restore transmission
|
||||
Given the transmission application is enabled
|
||||
When all torrents are removed from transmission
|
||||
And I upload a sample torrent to transmission
|
||||
And I create a backup of the transmission app data with name test_transmission
|
||||
And all torrents are removed from transmission
|
||||
And I restore the transmission app data backup with name test_transmission
|
||||
Then the transmission service should be running
|
||||
And there should be 1 torrents listed in transmission
|
||||
|
||||
Scenario: Disable transmission application
|
||||
Given the transmission application is enabled
|
||||
When I disable the transmission application
|
||||
Then the transmission site should not be available
|
||||
Loading…
x
Reference in New Issue
Block a user