UI
This commit is contained in:
@@ -81,6 +81,59 @@ class ServiceGroupLDAPIntegrationTests(TestCase):
|
||||
|
||||
@override_settings(MEMBERSHIP_TIERS=TIERS)
|
||||
class ServiceDisplayTests(TestCase):
|
||||
def test_published_tier_copy_matches_role_defaults(self):
|
||||
root = Path(__file__).absolute().parents[3]
|
||||
tiers = json.loads((root / "membership/tiers.eom.json").read_text(encoding="utf-8"))
|
||||
role = root.parent / "ansible-role-www/defaults/main.yml"
|
||||
if not role.exists():
|
||||
self.skipTest("Role checkout is not present in the application test image")
|
||||
import yaml
|
||||
|
||||
deployed = yaml.safe_load(role.read_text(encoding="utf-8"))["www_membership_tiers"]
|
||||
for key, tier in tiers.items():
|
||||
self.assertEqual(tier["description"], deployed[key]["description"])
|
||||
self.assertEqual(tier["benefits"], deployed[key]["benefits"])
|
||||
|
||||
def test_homepage_lists_services_with_clear_access_labels(self):
|
||||
root = Path(__file__).absolute().parents[3]
|
||||
homepage = root / "htdocs/index.html"
|
||||
if not homepage.exists():
|
||||
self.skipTest("Static website checkout is not present in the application test image")
|
||||
from html.parser import HTMLParser
|
||||
|
||||
class DirectoryParser(HTMLParser):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.active = False
|
||||
self.text = []
|
||||
self.links = []
|
||||
|
||||
def handle_starttag(self, tag, attrs):
|
||||
attributes = dict(attrs)
|
||||
if tag == "section" and attributes.get("id") == "services":
|
||||
self.active = True
|
||||
if self.active and tag == "a":
|
||||
self.links.append(attributes.get("href"))
|
||||
|
||||
def handle_endtag(self, tag):
|
||||
if tag == "section":
|
||||
self.active = False
|
||||
|
||||
def handle_data(self, data):
|
||||
if self.active:
|
||||
self.text.append(data)
|
||||
|
||||
parser = DirectoryParser()
|
||||
parser.feed(homepage.read_text(encoding="utf-8"))
|
||||
text = " ".join(parser.text)
|
||||
for name in ("Dex", "Discourse", "Matrix", "Gitea", "Mastodon", "PeerTube", "Hosted games", "Owncast"):
|
||||
self.assertIn(name, text)
|
||||
self.assertIn("Free · Level 0 and above", text)
|
||||
self.assertIn("Gold · Levels 3–5", text)
|
||||
self.assertIn("not currently offered", text)
|
||||
self.assertIn("/members/", parser.links)
|
||||
self.assertIn("https://element.eom.dev/", parser.links)
|
||||
|
||||
@override_settings(MEMBERSHIP_SERVICE_GROUPS={
|
||||
"0": ["cn=Dex Users," + BASE, "cn=Matrix Users," + BASE],
|
||||
"1": ["cn=Gitea Users," + BASE],
|
||||
|
||||
Reference in New Issue
Block a user