This repository has no description
1"""Unit tests for the issue quality filter (pure, no DB).
2
3Real examples are drawn from observed recommendation output: the engine was
4surfacing throwaway/test issues (e.g. "hello, world" whose body is "test issue
5to explore what tangled looks like") because issues are ranked purely by body
6embedding similarity, with no quality signal. These tests pin down what we drop
7and — just as importantly — what we must keep.
8"""
9
10from __future__ import annotations
11
12from app.quality import drop_issue, is_placeholder_issue, is_test_repo
13
14# --- repos that are clearly sandboxes / test scratchpads -------------------------
15def test_test_repo_by_name():
16 assert is_test_repo("tngl-mcp-test", "")
17 assert is_test_repo("test-repo", "")
18 assert is_test_repo("test100", "")
19 assert is_test_repo("sandbox", "")
20 assert is_test_repo("playground", "")
21 assert is_test_repo("my-demo", "")
22
23
24def test_test_repo_by_description():
25 assert is_test_repo("blaaaa", "adadadaddaaddada") # gibberish description
26 assert is_test_repo("whatever", "just a test")
27 assert is_test_repo("x", "this is a test")
28
29
30def test_real_repos_are_not_flagged():
31 assert not is_test_repo("knot-docker", "Docker config for a Tangled knotserver")
32 assert not is_test_repo("tangled-cli", "CLI for Tangled")
33 assert not is_test_repo("hydrant", "an atproto crawler")
34 assert not is_test_repo("drifting-starlight", "")
35 assert not is_test_repo("latest", "") # 'test' is a substring, not a token
36 assert not is_test_repo("fastest-router", "")
37 assert not is_test_repo("contest-platform", "")
38
39
40# --- placeholder / test issues ---------------------------------------------------
41def test_placeholder_issue_titles():
42 assert is_placeholder_issue("hello, world", "")
43 assert is_placeholder_issue("CLI test issue", "")
44 assert is_placeholder_issue("Test Issue", "")
45 assert is_placeholder_issue("[READ-ONLY]", "")
46
47
48def test_placeholder_issue_bodies():
49 assert is_placeholder_issue("hello, world", "test issue to explore what tangled looks like\n- and so on")
50 assert is_placeholder_issue("[READ-ONLY]", "this is a read-only mirror of https://github.com/npmx-dev/npmx")
51 assert is_placeholder_issue("untitled", "Testing programmatic access to Tangled via tang CLI")
52 assert is_placeholder_issue("x", "just testing, ignore this")
53 assert is_placeholder_issue("x", "lorem ipsum dolor sit amet")
54
55
56def test_real_issues_are_not_flagged():
57 assert not is_placeholder_issue(
58 "`KNOT_REPO_SCAN_PATH` doesn't seem to be respected",
59 "i've been hosting a knot for the past few versions and the log shows...",
60 )
61 assert not is_placeholder_issue("PR Phase 2: Reviewer Workflow (Commenting and Reviews)", "Implement the reviewer workflow")
62 assert not is_placeholder_issue("Finish migration from GitHub to Tangled", "- [x] Remove dependabot.yml file")
63 assert not is_placeholder_issue("[crawler] add `com.atproto.sync.listReposByCollection` support", "right now we use describeRepo")
64 assert not is_placeholder_issue("Improve Documentation", "Lots of little jobs here")
65 assert not is_placeholder_issue("Add tests for the ranker", "we need more test coverage on the scorer") # legit work *about* tests
66
67
68# --- combined gate used by the engine --------------------------------------------
69def test_drop_issue_combines_both_signals():
70 # dropped because the repo is a test repo (even if the issue title looks fine)
71 assert drop_issue("tngl-mcp-test", "", "Add README with project overview", "real-sounding body")
72 # dropped because the issue body is a placeholder (even if the repo looks fine)
73 assert drop_issue("static", "", "hello, world", "test issue to explore what tangled looks like")
74 # kept: real repo + real issue
75 assert not drop_issue("knot-docker", "Docker config", "KNOT_REPO_SCAN_PATH bug", "the scan path is ignored")