mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-28 08:03:36 +00:00
- Move non-reusable app specific step definitions and helper methods into <app>/tests/test_functional.py. - Merge reusable helper methods into plinth.tests.functional - Merge reusable step definitions into plinth.tests.functional.step_definitions - avahi, datetime, ikiwiki: Reuse common methods to avoid repetition. Avoid mapping from app nicknames to actual app names. - deluge, transmission: Make a copy of sample.torrent for each app to avoid clogging common place. - Implement functional.visit() to simplify a lot of browser.visit() calls. - Ensure that name of the mark on functional tests for an app is same as name of the app. This will help with predicting the mark when running tests for a particular app. Tests performed: - Run all functional tests. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
48 lines
1.8 KiB
Python
48 lines
1.8 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""
|
|
Functional, browser based tests for pagekite app.
|
|
"""
|
|
|
|
from pytest_bdd import parsers, scenarios, then, when
|
|
|
|
from plinth.tests import functional
|
|
|
|
scenarios('pagekite.feature')
|
|
|
|
|
|
@when(
|
|
parsers.parse('I configure pagekite with host {host:S}, port {port:d}, '
|
|
'kite name {kite_name:S} and kite secret {kite_secret:w}'))
|
|
def pagekite_configure(session_browser, host, port, kite_name, kite_secret):
|
|
_configure(session_browser, host, port, kite_name, kite_secret)
|
|
|
|
|
|
@then(
|
|
parsers.parse(
|
|
'pagekite should be configured with host {host:S}, port {port:d}, '
|
|
'kite name {kite_name:S} and kite secret {kite_secret:w}'))
|
|
def pagekite_assert_configured(session_browser, host, port, kite_name,
|
|
kite_secret):
|
|
assert (host, port, kite_name,
|
|
kite_secret) == _get_configuration(session_browser)
|
|
|
|
|
|
def _configure(browser, host, port, kite_name, kite_secret):
|
|
"""Configure pagekite basic parameters."""
|
|
functional.nav_to_module(browser, 'pagekite')
|
|
# time.sleep(0.250) # Wait for 200ms show animation to complete
|
|
browser.fill('pagekite-server_domain', host)
|
|
browser.fill('pagekite-server_port', str(port))
|
|
browser.fill('pagekite-kite_name', kite_name)
|
|
browser.fill('pagekite-kite_secret', kite_secret)
|
|
functional.submit(browser, form_class='form-configuration')
|
|
|
|
|
|
def _get_configuration(browser):
|
|
"""Return pagekite basic parameters."""
|
|
functional.nav_to_module(browser, 'pagekite')
|
|
return (browser.find_by_name('pagekite-server_domain').value,
|
|
int(browser.find_by_name('pagekite-server_port').value),
|
|
browser.find_by_name('pagekite-kite_name').value,
|
|
browser.find_by_name('pagekite-kite_secret').value)
|