| 1 | """Which topics are worth one web search to resolve an X handle. |
| 2 | |
| 3 | Gates on brevity rather than capitalization. Requiring a capital letter meant |
| 4 | the most common real-world spelling never resolved a handle: every recent run |
| 5 | on this machine -- bentgo, buzz, getenergy.com -- is lowercase. |
| 6 | """ |
| 7 | |
| 8 | import importlib.util |
| 9 | from pathlib import Path |
| 10 | |
| 11 | import pytest |
| 12 | |
| 13 | _CLI = Path(__file__).resolve().parent.parent / "skills" / "last30days" / "scripts" / "last30days.py" |
| 14 | |
| 15 | |
| 16 | def _cli(): |
| 17 | spec = importlib.util.spec_from_file_location("l30_cli", _CLI) |
| 18 | module = importlib.util.module_from_spec(spec) |
| 19 | try: |
| 20 | spec.loader.exec_module(module) |
| 21 | except SystemExit: |
| 22 | pass |
| 23 | return module |
| 24 | |
| 25 | |
| 26 | @pytest.mark.parametrize("topic", [ |
| 27 | "bentgo", |
| 28 | "Bentgo", |
| 29 | "peter steinberger", |
| 30 | "Peter Steinberger", |
| 31 | "getenergy.com", |
| 32 | "buzz by block", |
| 33 | "@steipete", |
| 34 | "claude code", |
| 35 | ]) |
| 36 | def test_entity_topics_resolve(topic): |
| 37 | assert _cli()._looks_like_entity_topic(topic) is True |
| 38 | |
| 39 | |
| 40 | @pytest.mark.parametrize("topic", [ |
| 41 | "best AI coding tools 2026", |
| 42 | "how to build agents", |
| 43 | "top tools for research", |
| 44 | "what is the best model?", |
| 45 | "", |
| 46 | ]) |
| 47 | def test_theme_topics_do_not_resolve(topic): |
| 48 | assert _cli()._looks_like_entity_topic(topic) is False |
| 49 | |
| 50 | |
| 51 | def test_casing_does_not_change_the_verdict(): |
| 52 | """The regression this replaces: capitalization decided whether a subject's |
| 53 | own posts could be protected.""" |
| 54 | cli = _cli() |
| 55 | for lower, upper in [("bentgo", "Bentgo"), ("peter steinberger", "Peter Steinberger")]: |
| 56 | assert cli._looks_like_entity_topic(lower) == cli._looks_like_entity_topic(upper) |
| 57 | |
| 58 | |
| 59 | def test_question_shaped_topics_are_themes(): |
| 60 | assert _cli()._looks_like_entity_topic("who is peter steinberger?") is False |
| 61 |