mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
tests: functional: Re-organize step definitions and helper methods
- 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>
This commit is contained in:
1 parent
8fac6a71fe
commit
80dff7bf9c
53 files changed
+3340
-3410
No files matched your search
@@ -3,6 +3,73 @@
|
||||
Functional, browser based tests for ttrss app.
|
||||
"""
|
||||
|
||||
from pytest_bdd import scenarios
|
||||
from pytest_bdd import given, scenarios, then, when
|
||||
|
||||
from plinth.tests import functional
|
||||
|
||||
scenarios('ttrss.feature')
|
||||
|
||||
|
||||
@given('I subscribe to a feed in ttrss')
|
||||
def ttrss_subscribe(session_browser):
|
||||
_subscribe(session_browser)
|
||||
|
||||
|
||||
@when('I unsubscribe from the feed in ttrss')
|
||||
def ttrss_unsubscribe(session_browser):
|
||||
_unsubscribe(session_browser)
|
||||
|
||||
|
||||
@then('I should be subscribed to the feed in ttrss')
|
||||
def ttrss_assert_subscribed(session_browser):
|
||||
assert _is_subscribed(session_browser)
|
||||
|
||||
|
||||
def _ttrss_load_main_interface(browser):
|
||||
"""Load the TT-RSS interface."""
|
||||
functional.access_url(browser, 'ttrss')
|
||||
overlay = browser.find_by_id('overlay')
|
||||
functional.eventually(lambda: not overlay.visible)
|
||||
|
||||
|
||||
def _is_feed_shown(browser, invert=False):
|
||||
return browser.is_text_present('Planet Debian') != invert
|
||||
|
||||
|
||||
def _subscribe(browser):
|
||||
"""Subscribe to a feed in TT-RSS."""
|
||||
_ttrss_load_main_interface(browser)
|
||||
browser.find_by_text('Actions...').click()
|
||||
browser.find_by_text('Subscribe to feed...').click()
|
||||
browser.find_by_id('feedDlg_feedUrl').fill(
|
||||
'https://planet.debian.org/atom.xml')
|
||||
browser.find_by_text('Subscribe').click()
|
||||
if browser.is_text_present('You are already subscribed to this feed.'):
|
||||
browser.find_by_text('Cancel').click()
|
||||
|
||||
expand = browser.find_by_css('span.dijitTreeExpandoClosed')
|
||||
if expand:
|
||||
expand.first.click()
|
||||
|
||||
assert functional.eventually(_is_feed_shown, [browser])
|
||||
|
||||
|
||||
def _unsubscribe(browser):
|
||||
"""Unsubscribe from a feed in TT-RSS."""
|
||||
_ttrss_load_main_interface(browser)
|
||||
expand = browser.find_by_css('span.dijitTreeExpandoClosed')
|
||||
if expand:
|
||||
expand.first.click()
|
||||
|
||||
browser.find_by_text('Planet Debian').click()
|
||||
browser.execute_script("quickMenuGo('qmcRemoveFeed')")
|
||||
prompt = browser.get_alert()
|
||||
prompt.accept()
|
||||
|
||||
assert functional.eventually(_is_feed_shown, [browser, True])
|
||||
|
||||
|
||||
def _is_subscribed(browser):
|
||||
"""Return whether subscribed to a feed in TT-RSS."""
|
||||
_ttrss_load_main_interface(browser)
|
||||
return browser.is_text_present('Planet Debian')
|
||||
Reference in new issue
Block a user