twitter tests fix

This commit is contained in:
msramalho
2025-06-17 23:51:03 +01:00
parent a3ae9ebbb3
commit 76fd329fe5
2 changed files with 8 additions and 5 deletions

View File

@@ -1,3 +1,4 @@
from datetime import timezone
import json import json
import re import re
import mimetypes import mimetypes
@@ -91,7 +92,9 @@ class TwitterApiExtractor(Extractor):
result = Metadata() result = Metadata()
result.set_title(tweet.data.text) result.set_title(tweet.data.text)
result.set_timestamp(get_datetime_from_str(tweet.data.created_at, "%Y-%m-%dT%H:%M:%S.%fZ")) result.set_timestamp(
get_datetime_from_str(tweet.data.created_at, "%Y-%m-%dT%H:%M:%S.%fZ").replace(tzinfo=timezone.utc)
)
urls = [] urls = []
if tweet.includes: if tweet.includes:

View File

@@ -140,22 +140,22 @@ class TestTwitterApiExtractor(TestExtractorBase):
( (
"https://x.com/SozinhoRamalho/status/1876710769913450647", "https://x.com/SozinhoRamalho/status/1876710769913450647",
"ignore tweet, testing sensitivity warning nudity https://t.co/t3u0hQsSB1", "ignore tweet, testing sensitivity warning nudity https://t.co/t3u0hQsSB1",
datetime.datetime(2024, 12, 31, 14, 18, 33, tzinfo=datetime.timezone.utc), datetime.datetime(2025, 1, 7, 19, 21, 29, tzinfo=datetime.timezone.utc),
), ),
( (
"https://x.com/SozinhoRamalho/status/1876710875475681357", "https://x.com/SozinhoRamalho/status/1876710875475681357",
"ignore tweet, testing sensitivity warning violence https://t.co/syYDSkpjZD", "ignore tweet, testing sensitivity warning violence https://t.co/syYDSkpjZD",
datetime.datetime(2024, 12, 31, 14, 18, 33, tzinfo=datetime.timezone.utc), datetime.datetime(2025, 1, 7, 19, 21, 54, tzinfo=datetime.timezone.utc),
), ),
( (
"https://x.com/SozinhoRamalho/status/1876711053813227618", "https://x.com/SozinhoRamalho/status/1876711053813227618",
"ignore tweet, testing sensitivity warning sensitive https://t.co/XE7cRdjzYq", "ignore tweet, testing sensitivity warning sensitive https://t.co/XE7cRdjzYq",
datetime.datetime(2024, 12, 31, 14, 18, 33, tzinfo=datetime.timezone.utc), datetime.datetime(2025, 1, 7, 19, 22, 37, tzinfo=datetime.timezone.utc),
), ),
( (
"https://x.com/SozinhoRamalho/status/1876711141314801937", "https://x.com/SozinhoRamalho/status/1876711141314801937",
"ignore tweet, testing sensitivity warning nudity, violence, sensitivity https://t.co/YxCFbbhYE3", "ignore tweet, testing sensitivity warning nudity, violence, sensitivity https://t.co/YxCFbbhYE3",
datetime.datetime(2024, 12, 31, 14, 18, 33, tzinfo=datetime.timezone.utc), datetime.datetime(2025, 1, 7, 19, 22, 58, tzinfo=datetime.timezone.utc),
), ),
], ],
) )