| 1 | """The Polymarket footer names a recurring series once. |
| 2 | |
| 3 | The "Elon Musk" run of 2026-11-10 printed three brackets of one weekly |
| 4 | "how many tweets" series: |
| 5 | |
| 6 | Polymarket: 13 markets | Elon Musk post 260-279 tweets from Nov 6 to |
| 7 | Nov 13, 2026 24%, Elon Musk post 280-299 tweets from Nov 10 to Nov 17, |
| 8 | 2026 12%, Elon Musk post 40-64 tweets from Nov 9 to Nov 11, 2026 64% |
| 9 | |
| 10 | while markets on his net worth, a meeting with Putin and a return to the |
| 11 | administration were in the same run. The items below are the Polymarket |
| 12 | section of that run's saved file: titles, lead questions, prices and volumes. |
| 13 | """ |
| 14 | |
| 15 | from lib import polymarket, render, schema |
| 16 | |
| 17 | TOPIC = "Elon Musk" |
| 18 | |
| 19 | # (event id, event title, headline question, price, volume) |
| 20 | SAVED = [ |
| 21 | ("1302903", "Elon Musk Net Worth on November 30?", |
| 22 | "Will Elon Musk's net worth be between $800B and $900B on November 30?", 0.43, 8433.4), |
| 23 | ("1305851", "Elon Musk # tweets November 6 - November 13, 2026?", |
| 24 | "Will Elon Musk post 260-279 tweets from November 6 to November 13, 2026?", 0.24, 695083.2), |
| 25 | ("1244070", "Elon Musk # tweets in November 2026?", |
| 26 | "Will Elon Musk post 1000+ tweets in November 2026?", 0.82, 112594.7), |
| 27 | ("1329688", "Elon Musk # tweets November 10 - November 17, 2026?", |
| 28 | "Will Elon Musk post 280-299 tweets from November 10 to November 17, 2026?", 0.12, 253060.4), |
| 29 | ("1354158", "Elon Musk # tweets November 13 - November 20, 2026?", |
| 30 | "Will Elon Musk post 280-299 tweets from November 13 to November 20, 2026?", 0.12, 32535.5), |
| 31 | ("1333415", "Elon Musk # tweets November 9 - November 11, 2026?", |
| 32 | "Will Elon Musk post 40-64 tweets from November 9 to November 11, 2026?", 0.64, 217052.5), |
| 33 | ("1280261", "Elon Musk meets with Putin by...?", |
| 34 | "Elon Musk meets with Putin by December 31, 2026?", 0.093, 4153.9), |
| 35 | ("1116368", "Elon Musk out as Project Meridian co-lead by January 27?", |
| 36 | "Elon Musk out as Project Meridian co-lead by January 27?", 0.56, 0), |
| 37 | ("149602", "Will Elon Musk rejoin the Trump Administration in 2026?", |
| 38 | "Will Elon Musk rejoin the Trump Administration in 2026?", 0.038, 0), |
| 39 | ("73198", "Will Elon Musk announce Presidential run before 2027?", |
| 40 | "Will Elon Musk announce Presidential run before 2027?", 0.009, 0), |
| 41 | ] |
| 42 | |
| 43 | |
| 44 | def _item(event_id, title, question, price, volume): |
| 45 | return schema.SourceItem( |
| 46 | item_id=event_id, source="polymarket", title=title, body="", |
| 47 | url=f"https://polymarket.com/event/{event_id}", |
| 48 | engagement={"volume": volume} if volume else {}, |
| 49 | metadata={"question": question, "headline": {"question": question, "price": price}}, |
| 50 | ) |
| 51 | |
| 52 | |
| 53 | def _footer(rows, limit=3): |
| 54 | return render._polymarket_top_markets([_item(*row) for row in rows], limit=limit, topic=TOPIC) |
| 55 | |
| 56 | |
| 57 | def test_weekly_tweet_brackets_share_one_series_key(): |
| 58 | keys = {polymarket.series_key(title) for _id, title, *_ in SAVED if "# tweets" in title} |
| 59 | |
| 60 | assert keys == {"elon musk tweets"} |
| 61 | |
| 62 | |
| 63 | def test_tweet_counts_are_count_series_and_net_worth_is_not(): |
| 64 | assert polymarket.is_count_series("Elon Musk # tweets November 6 - November 13, 2026?") |
| 65 | assert polymarket.is_count_series("", "Will Elon Musk post 260-279 tweets from November 6?") |
| 66 | assert not polymarket.is_count_series( |
| 67 | "Elon Musk Net Worth on November 30?", |
| 68 | "Will Elon Musk's net worth be between $800B and $900B on November 30?", |
| 69 | ) |
| 70 | |
| 71 | |
| 72 | def test_saved_run_names_substantive_markets_not_three_tweet_brackets(): |
| 73 | lines = _footer(SAVED) |
| 74 | |
| 75 | assert len(lines) == 3 |
| 76 | assert not any("tweets" in line for line in lines) |
| 77 | assert lines[0].startswith("Elon Musk's net worth between $800B and $900B") |
| 78 | assert lines[1] == "Elon Musk meets with Putin by Dec 31, 2026 9.3%" |
| 79 | |
| 80 | |
| 81 | def test_count_series_fills_a_slot_once_when_slots_remain(): |
| 82 | rows = [row for row in SAVED if "# tweets" in row[1]] + [SAVED[0]] |
| 83 | |
| 84 | lines = _footer(rows) |
| 85 | |
| 86 | assert len(lines) == 2 |
| 87 | assert "net worth" in lines[0] |
| 88 | # The most traded bracket stands for the series. |
| 89 | assert lines[1] == "Elon Musk post 260-279 tweets from Nov 6 to Nov 13, 2026 24%" |
| 90 | |
| 91 | |
| 92 | def test_only_a_count_series_still_names_it_once(): |
| 93 | lines = _footer([row for row in SAVED if "# tweets" in row[1]]) |
| 94 | |
| 95 | assert lines == ["Elon Musk post 260-279 tweets from Nov 6 to Nov 13, 2026 24%"] |
| 96 |