59 lines
1.9 KiB
Python
59 lines
1.9 KiB
Python
"""Regression checks for the public download-page copy."""
|
||
from html.parser import HTMLParser
|
||
from pathlib import Path
|
||
import unittest
|
||
|
||
|
||
class Page(HTMLParser):
|
||
def __init__(self, text):
|
||
super().__init__()
|
||
self.links = []
|
||
self.visible = []
|
||
self.header = False
|
||
self.header_links = []
|
||
self.feed(text)
|
||
|
||
def handle_starttag(self, tag, attrs):
|
||
if tag == 'header':
|
||
self.header = True
|
||
if tag == 'a':
|
||
href = dict(attrs).get('href', '')
|
||
self.links.append(href)
|
||
if self.header:
|
||
self.header_links.append(href)
|
||
|
||
def handle_endtag(self, tag):
|
||
if tag == 'header':
|
||
self.header = False
|
||
|
||
def handle_data(self, data):
|
||
self.visible.append(data)
|
||
|
||
|
||
class WebsiteCopyTests(unittest.TestCase):
|
||
def setUp(self):
|
||
self.page = Page((Path(__file__).resolve().parents[1] / 'website/index.html').read_text())
|
||
|
||
def test_header_has_no_github_source_link(self):
|
||
self.assertFalse(any('github.com' in href for href in self.page.header_links))
|
||
self.assertNotIn('Source on GitHub', ''.join(self.page.visible))
|
||
|
||
def test_release_has_no_upgrade_comment(self):
|
||
self.assertNotIn('Updates v0.4.2 without uninstalling', ''.join(self.page.visible))
|
||
|
||
def test_footer_has_no_provider_disclaimer(self):
|
||
self.assertNotIn(
|
||
'External catalog and media providers. Use only media you’re entitled to access.',
|
||
''.join(self.page.visible),
|
||
)
|
||
|
||
def test_version_download_and_source_archive_remain(self):
|
||
self.assertIn('v0.4.4', ''.join(self.page.visible))
|
||
self.assertIn('/downloads/reelbox-0.4.4-arm64.apk', self.page.links)
|
||
self.assertIn('/downloads/reelbox-0.4.4-source.zip', self.page.links)
|
||
self.assertIn('Source archive', ''.join(self.page.visible))
|
||
|
||
|
||
if __name__ == '__main__':
|
||
unittest.main()
|