rssbridge: Add functional tests

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Sunil Mohan Adapa 2022-07-15 20:17:32 -07:00
parent 556c476de4
commit b2e6508b16
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
2 changed files with 58 additions and 0 deletions

View File

@ -0,0 +1,57 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for RSS-Bridge app.
"""
import json
import ssl
import subprocess
import urllib
import pytest
from plinth.tests import functional
class TestRSSBridgeApp(functional.BaseAppTests):
app_name = 'rssbridge'
has_service = False
has_web = True
def test_active_bridges(self, session_browser):
"""Check that bridges are active."""
functional.app_enable(session_browser, self.app_name)
functional.visit(session_browser, '/rss-bridge/')
assert session_browser.find_by_css(
'#bridge-Wikipedia button[type="submit"]')
def test_feed_html(self, session_browser):
"""Check that a feed is properly rendered."""
functional.app_enable(session_browser, self.app_name)
url = '/rss-bridge/?action=display&bridge=Wikipedia&' \
'language=en&subject=tfa&format=Html'
functional.visit(session_browser, url)
assert not session_browser.find_by_css('.exception-message')
assert session_browser.find_by_css('.feeditem')
def test_feed_json(self, session_browser):
"""Check that a feed is properly rendered."""
functional.app_enable(session_browser, self.app_name)
path = '/rss-bridge/?action=display&bridge=Wikipedia&' \
'language=en&subject=tfa&format=Json'
url = functional.config['DEFAULT']['url'] + path
# Unauthorized
result = subprocess.run(['curl', '-k', '--basic', url],
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL, check=True)
assert '401 Unauthorized' in result.stdout.decode()
# Authorized
username = functional.config['DEFAULT']['username']
password = functional.config['DEFAULT']['password']
result = subprocess.run(
['curl', '-k', '--basic', '--user', f'{username}:{password}', url],
stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, check=True)
feed = json.loads(result.stdout)
assert len(feed['items'])

View File

@ -46,6 +46,7 @@ _site_url = {
'jsxc': '/plinth/apps/jsxc/jsxc/',
'cockpit': '/_cockpit/',
'syncthing': '/syncthing/',
'rssbridge': '/rss-bridge/',
}
_sys_modules = [