0a9ff16dfc
v3 rewrites the search engine from the ground up: - Intelligent pre-research: resolves X handles, GitHub repos, subreddits, TikTok hashtags, and YouTube channels before searching - GitHub person-mode: PR velocity, top repos by stars, release notes - GitHub project-mode: live star counts, README, releases, top issues - ELI5 mode: plain language synthesis, no jargon - 13+ sources: Reddit, X, YouTube, TikTok, Instagram, HN, Polymarket, GitHub, Threads, Pinterest, Perplexity, Bluesky, Web - Free Reddit comments via public JSON (no API key needed) - Fun judge v2: humor scoring baked into narrative - Cookie consent before browser scanning - 10,000 free ScrapeCreators calls - 1,012 tests Thank you to the community contributors whose issues and PRs shaped v3: @uppinote20 (#143), @zerone0x (#134, #136), @thinkun (#116), @thomasmktong (#124), @fanispoulinakisai-boop (#100), @pejmanjohn (#78), @zl190 (#115), @hnshah (#84, #85, #86) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
69 lines
1.9 KiB
Python
69 lines
1.9 KiB
Python
import json
|
|
import sys
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts"))
|
|
|
|
from lib.xai_x import parse_x_response
|
|
|
|
|
|
def _wrap_items(items):
|
|
"""Wrap items list in the xAI response envelope."""
|
|
payload = json.dumps({"items": items})
|
|
return {
|
|
"output": [
|
|
{
|
|
"type": "message",
|
|
"content": [{"type": "output_text", "text": payload}],
|
|
}
|
|
]
|
|
}
|
|
|
|
|
|
class TestXaiXEngagementZero(unittest.TestCase):
|
|
def test_zero_likes_preserved(self):
|
|
raw_items = [
|
|
{
|
|
"text": "test",
|
|
"url": "https://x.com/u/status/1",
|
|
"engagement": {"likes": 0, "reposts": 5},
|
|
"relevance": 0.8,
|
|
}
|
|
]
|
|
items = parse_x_response(_wrap_items(raw_items))
|
|
self.assertEqual(0, items[0]["engagement"]["likes"])
|
|
self.assertEqual(5, items[0]["engagement"]["reposts"])
|
|
|
|
def test_none_engagement_when_missing(self):
|
|
raw_items = [
|
|
{
|
|
"text": "test",
|
|
"url": "https://x.com/u/status/1",
|
|
"engagement": {},
|
|
"relevance": 0.8,
|
|
}
|
|
]
|
|
items = parse_x_response(_wrap_items(raw_items))
|
|
self.assertIsNone(items[0]["engagement"]["likes"])
|
|
|
|
def test_nonzero_engagement(self):
|
|
raw_items = [
|
|
{
|
|
"text": "test",
|
|
"url": "https://x.com/u/status/1",
|
|
"engagement": {"likes": 42, "reposts": 3, "replies": 1, "quotes": 0},
|
|
"relevance": 0.9,
|
|
}
|
|
]
|
|
items = parse_x_response(_wrap_items(raw_items))
|
|
eng = items[0]["engagement"]
|
|
self.assertEqual(42, eng["likes"])
|
|
self.assertEqual(3, eng["reposts"])
|
|
self.assertEqual(1, eng["replies"])
|
|
self.assertEqual(0, eng["quotes"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|