Some checks failed
Windows project source guards / test (push) Failing after 2m6s
The Telegram channel and "Купить подписку" buttons leave the "О проекте" page and live in a new last sidebar item, in their own ui/about_us package. The VPN bot where a subscription is bought stands on top, then the four Telegram channels, then the wiki, Git and both backup address lists. The bot keeps its kvnwin_about ad label. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
42 lines
1.6 KiB
Python
42 lines
1.6 KiB
Python
import re
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
ABOUT_US_LINKS = ROOT / "xray_fluent/ui/about_us/links.py"
|
|
LABEL_RE = re.compile(r"[A-Za-z0-9_-]{1,64}")
|
|
BOT_URL_RE = re.compile(r"https://t\.me/zapretvpns_bot(?:\?start=([^\s)\"']*))?")
|
|
|
|
|
|
def _labels(path: Path) -> list[str | None]:
|
|
return [m.group(1) for m in BOT_URL_RE.finditer(path.read_text(encoding="utf-8"))]
|
|
|
|
|
|
class BotAdLabelTests(unittest.TestCase):
|
|
def test_about_us_button_carries_its_own_label(self) -> None:
|
|
source = ABOUT_US_LINKS.read_text(encoding="utf-8")
|
|
self.assertIn(
|
|
'BOT_ABOUT_URL = "https://t.me/zapretvpns_bot?start=kvnwin_about"', source
|
|
)
|
|
self.assertIn("BOT = AboutUsLink(", source)
|
|
self.assertEqual(_labels(ABOUT_US_LINKS), ["kvnwin_about"])
|
|
|
|
def test_old_about_page_no_longer_holds_the_bot_link(self) -> None:
|
|
self.assertEqual(_labels(ROOT / "xray_fluent/ui/about_page.py"), [])
|
|
|
|
def test_readme_links_have_distinct_labels(self) -> None:
|
|
labels = _labels(ROOT / "docs/README.md")
|
|
self.assertEqual(labels, ["kvnwin_readme_keys", "kvnwin_readme_nokey"])
|
|
|
|
def test_labels_follow_ad_source_rules(self) -> None:
|
|
for rel in ("xray_fluent/ui/about_us/links.py", "docs/README.md"):
|
|
for label in _labels(ROOT / rel):
|
|
with self.subTest(file=rel, label=label):
|
|
self.assertIsNotNone(label)
|
|
self.assertRegex(label, LABEL_RE.pattern)
|
|
self.assertRegex(label, r"^kvnwin_")
|
|
self.assertFalse(label.startswith("ref_"))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|