From 4f144d15911cd546b3c7f9d8b8e1c22e141c7ae3 Mon Sep 17 00:00:00 2001 From: jackwener Date: Tue, 10 Mar 2026 12:08:47 +0800 Subject: [PATCH] test: track parser fixture files --- .gitignore | 1 + tests/fixtures/followers_page.json | 53 +++++++ tests/fixtures/home_timeline.json | 208 ++++++++++++++++++++++++++++ tests/fixtures/list_timeline.json | 75 ++++++++++ tests/fixtures/search_timeline.json | 107 ++++++++++++++ tests/fixtures/tweet_detail.json | 118 ++++++++++++++++ 6 files changed, 562 insertions(+) create mode 100644 tests/fixtures/followers_page.json create mode 100644 tests/fixtures/home_timeline.json create mode 100644 tests/fixtures/list_timeline.json create mode 100644 tests/fixtures/search_timeline.json create mode 100644 tests/fixtures/tweet_detail.json diff --git a/.gitignore b/.gitignore index f6d2e49..5c3c9b2 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ build/ .venv/ .env *.json +!tests/fixtures/*.json !config.yaml diff --git a/tests/fixtures/followers_page.json b/tests/fixtures/followers_page.json new file mode 100644 index 0000000..3da96b0 --- /dev/null +++ b/tests/fixtures/followers_page.json @@ -0,0 +1,53 @@ +{ + "data": { + "user": { + "result": { + "timeline": { + "timeline": { + "instructions": [ + { + "type": "TimelineAddEntries", + "entries": [ + { + "entryId": "user-1", + "content": { + "entryType": "TimelineTimelineItem", + "itemContent": { + "user_results": { + "result": { + "rest_id": "f1", + "is_blue_verified": true, + "legacy": { + "name": "Follower One", + "screen_name": "follower1", + "description": "first follower", + "location": "Earth", + "followers_count": 123, + "friends_count": 45, + "statuses_count": 67, + "favourites_count": 89, + "profile_image_url_https": "https://img/f1.jpg", + "created_at": "Sat Mar 08 10:00:00 +0000 2026" + } + } + } + } + } + }, + { + "entryId": "cursor-bottom", + "content": { + "entryType": "TimelineTimelineCursor", + "cursorType": "Bottom", + "value": "followers-cursor" + } + } + ] + } + ] + } + } + } + } + } +} diff --git a/tests/fixtures/home_timeline.json b/tests/fixtures/home_timeline.json new file mode 100644 index 0000000..df44576 --- /dev/null +++ b/tests/fixtures/home_timeline.json @@ -0,0 +1,208 @@ +{ + "data": { + "home": { + "home_timeline_urt": { + "instructions": [ + { + "type": "TimelineAddEntries", + "entries": [ + { + "entryId": "tweet-1", + "content": { + "entryType": "TimelineTimelineItem", + "itemContent": { + "tweet_results": { + "result": { + "__typename": "Tweet", + "rest_id": "1", + "core": { + "user_results": { + "result": { + "rest_id": "u1", + "core": { + "name": "Alice", + "screen_name": "alice" + }, + "legacy": { + "name": "Alice", + "screen_name": "alice", + "verified": false, + "profile_image_url_https": "https://img/alice.jpg" + } + } + } + }, + "legacy": { + "full_text": "Hello\nworld", + "created_at": "Sat Mar 08 12:00:00 +0000 2026", + "favorite_count": 10, + "retweet_count": 2, + "reply_count": 1, + "quote_count": 0, + "bookmark_count": 3, + "lang": "en", + "entities": { + "urls": [ + { + "expanded_url": "https://example.com/post" + } + ] + }, + "extended_entities": { + "media": [ + { + "type": "photo", + "media_url_https": "https://pbs.twimg.com/1.jpg", + "original_info": { + "width": 1200, + "height": 800 + } + } + ] + } + }, + "views": { + "count": "1234" + } + } + } + } + } + }, + { + "entryId": "tweet-2", + "content": { + "entryType": "TimelineTimelineItem", + "itemContent": { + "tweet_results": { + "result": { + "__typename": "Tweet", + "rest_id": "2", + "core": { + "user_results": { + "result": { + "rest_id": "u2", + "core": { + "name": "Bob", + "screen_name": "bob" + }, + "legacy": { + "name": "Bob", + "screen_name": "bob", + "verified": true, + "profile_image_url_https": "https://img/bob.jpg" + } + } + } + }, + "legacy": { + "full_text": "RT wrapper", + "created_at": "Sat Mar 08 12:01:00 +0000 2026", + "favorite_count": 5, + "retweet_count": 1, + "reply_count": 0, + "quote_count": 0, + "bookmark_count": 0, + "lang": "zh", + "entities": { + "urls": [] + }, + "retweeted_status_result": { + "result": { + "__typename": "Tweet", + "rest_id": "20", + "core": { + "user_results": { + "result": { + "rest_id": "u20", + "core": { + "name": "Carol", + "screen_name": "carol" + }, + "legacy": { + "name": "Carol", + "screen_name": "carol", + "verified": false, + "profile_image_url_https": "https://img/carol.jpg" + } + } + } + }, + "quoted_status_result": { + "result": { + "__typename": "Tweet", + "rest_id": "30", + "core": { + "user_results": { + "result": { + "rest_id": "u30", + "core": { + "name": "Dan", + "screen_name": "dan" + }, + "legacy": { + "name": "Dan", + "screen_name": "dan", + "verified": false, + "profile_image_url_https": "https://img/dan.jpg" + } + } + } + }, + "legacy": { + "full_text": "quoted text", + "created_at": "Sat Mar 08 11:58:00 +0000 2026", + "favorite_count": 1, + "retweet_count": 0, + "reply_count": 0, + "quote_count": 0, + "bookmark_count": 0, + "lang": "en", + "entities": { + "urls": [] + } + } + } + }, + "legacy": { + "full_text": "original retweeted post", + "created_at": "Sat Mar 08 11:59:00 +0000 2026", + "favorite_count": 50, + "retweet_count": 7, + "reply_count": 2, + "quote_count": 1, + "bookmark_count": 4, + "lang": "en", + "entities": { + "urls": [] + } + }, + "views": { + "count": "999" + } + } + } + }, + "views": { + "count": "10" + } + } + } + } + } + }, + { + "entryId": "cursor-bottom", + "content": { + "entryType": "TimelineTimelineCursor", + "cursorType": "Bottom", + "value": "cursor-bottom-1" + } + } + ] + } + ] + } + } + } +} diff --git a/tests/fixtures/list_timeline.json b/tests/fixtures/list_timeline.json new file mode 100644 index 0000000..9e9220a --- /dev/null +++ b/tests/fixtures/list_timeline.json @@ -0,0 +1,75 @@ +{ + "data": { + "list": { + "tweets_timeline": { + "timeline": { + "instructions": [ + { + "type": "TimelineAddEntries", + "entries": [ + { + "entryId": "list-tweet-1", + "content": { + "entryType": "TimelineTimelineItem", + "itemContent": { + "tweet_results": { + "result": { + "__typename": "TweetWithVisibilityResults", + "tweet": { + "__typename": "Tweet", + "rest_id": "700", + "core": { + "user_results": { + "result": { + "rest_id": "u700", + "core": { + "name": "Lister", + "screen_name": "lister" + }, + "legacy": { + "name": "Lister", + "screen_name": "lister", + "verified": true, + "profile_image_url_https": "https://img/lister.jpg" + } + } + } + }, + "legacy": { + "full_text": "list timeline tweet", + "created_at": "Sat Mar 08 13:10:00 +0000 2026", + "favorite_count": 8, + "retweet_count": 2, + "reply_count": 1, + "quote_count": 0, + "bookmark_count": 1, + "lang": "zh", + "entities": { + "urls": [] + } + }, + "views": { + "count": "321" + } + } + } + } + } + } + }, + { + "entryId": "cursor-bottom", + "content": { + "entryType": "TimelineTimelineCursor", + "cursorType": "Bottom", + "value": "list-cursor" + } + } + ] + } + ] + } + } + } + } +} diff --git a/tests/fixtures/search_timeline.json b/tests/fixtures/search_timeline.json new file mode 100644 index 0000000..ca686ff --- /dev/null +++ b/tests/fixtures/search_timeline.json @@ -0,0 +1,107 @@ +{ + "data": { + "search_by_raw_query": { + "search_timeline": { + "timeline": { + "instructions": [ + { + "type": "TimelineAddEntries", + "entries": [ + { + "entryId": "search-module-1", + "content": { + "entryType": "TimelineTimelineModule", + "items": [ + { + "item": { + "itemContent": { + "tweet_results": { + "result": { + "__typename": "TweetWithVisibilityResults", + "tweet": { + "__typename": "Tweet", + "rest_id": "500", + "core": { + "user_results": { + "result": { + "rest_id": "u500", + "core": { + "name": "Searcher", + "screen_name": "searcher" + }, + "legacy": { + "name": "Searcher", + "screen_name": "searcher", + "verified": false, + "profile_image_url_https": "https://img/searcher.jpg" + } + } + } + }, + "legacy": { + "full_text": "search result with video", + "created_at": "Sat Mar 08 13:00:00 +0000 2026", + "favorite_count": 12, + "retweet_count": 4, + "reply_count": 1, + "quote_count": 0, + "bookmark_count": 2, + "lang": "en", + "entities": { + "urls": [] + }, + "extended_entities": { + "media": [ + { + "type": "video", + "media_url_https": "https://pbs.twimg.com/thumb.jpg", + "original_info": { + "width": 1280, + "height": 720 + }, + "video_info": { + "variants": [ + { + "content_type": "video/mp4", + "bitrate": 832000, + "url": "https://video-low.mp4" + }, + { + "content_type": "video/mp4", + "bitrate": 2176000, + "url": "https://video-high.mp4" + } + ] + } + } + ] + } + }, + "views": { + "count": "4321" + } + } + } + } + } + } + } + ] + } + }, + { + "entryId": "cursor-bottom", + "content": { + "entryType": "TimelineTimelineCursor", + "cursorType": "Bottom", + "value": "search-cursor" + } + } + ] + } + ] + } + } + } + } +} diff --git a/tests/fixtures/tweet_detail.json b/tests/fixtures/tweet_detail.json new file mode 100644 index 0000000..756ac2a --- /dev/null +++ b/tests/fixtures/tweet_detail.json @@ -0,0 +1,118 @@ +{ + "data": { + "threaded_conversation_with_injections_v2": { + "instructions": [ + { + "type": "TimelineAddEntries", + "entries": [ + { + "entryId": "conversation-thread", + "content": { + "items": [ + { + "item": { + "itemContent": { + "tweet_results": { + "result": { + "__typename": "Tweet", + "rest_id": "100", + "core": { + "user_results": { + "result": { + "rest_id": "ua", + "core": { + "name": "Author A", + "screen_name": "authora" + }, + "legacy": { + "name": "Author A", + "screen_name": "authora", + "verified": false, + "profile_image_url_https": "https://img/a.jpg" + } + } + } + }, + "legacy": { + "full_text": "root tweet", + "created_at": "Sat Mar 08 12:10:00 +0000 2026", + "favorite_count": 100, + "retweet_count": 10, + "reply_count": 2, + "quote_count": 1, + "bookmark_count": 8, + "lang": "en", + "entities": { + "urls": [] + } + }, + "views": { + "count": "8000" + } + } + } + } + } + }, + { + "item": { + "itemContent": { + "tweet_results": { + "result": { + "__typename": "Tweet", + "rest_id": "101", + "core": { + "user_results": { + "result": { + "rest_id": "ub", + "core": { + "name": "Author B", + "screen_name": "authorb" + }, + "legacy": { + "name": "Author B", + "screen_name": "authorb", + "verified": false, + "profile_image_url_https": "https://img/b.jpg" + } + } + } + }, + "legacy": { + "full_text": "reply tweet", + "created_at": "Sat Mar 08 12:12:00 +0000 2026", + "favorite_count": 5, + "retweet_count": 1, + "reply_count": 0, + "quote_count": 0, + "bookmark_count": 0, + "lang": "en", + "entities": { + "urls": [] + } + }, + "views": { + "count": "100" + } + } + } + } + } + } + ] + } + }, + { + "entryId": "cursor-bottom", + "content": { + "entryType": "TimelineTimelineCursor", + "cursorType": "Bottom", + "value": "conversation-cursor" + } + } + ] + } + ] + } + } +}