mirror of
https://github.com/zedeus/nitter
synced 2026-09-05 14:49:32 +00:00
Fix oEmbed CI: accept any host in URL parsing
This commit is contained in:
parent
7f6c083dce
commit
06e59f0615
2 changed files with 17 additions and 2 deletions
|
|
@ -230,13 +230,14 @@ class OEmbedApiTest(BaseTestCase):
|
|||
|
||||
class OEmbedDiscoveryTest(BaseTestCase):
|
||||
"""Test oEmbed discovery link tags on tweet pages."""
|
||||
base_url = 'http://localhost:8080'
|
||||
|
||||
def test_tweet_page_has_oembed_link_tag(self):
|
||||
self.open_nitter('elonmusk/status/1141367104702038016')
|
||||
self.assert_element_present('link[type="application/json+oembed"]')
|
||||
|
||||
def test_oembed_link_tag_points_to_api(self):
|
||||
resp = requests.get('http://localhost:8080/elonmusk/status/1141367104702038016')
|
||||
resp = requests.get(f'{self.base_url}/elonmusk/status/1141367104702038016')
|
||||
self.assertIn('application/json+oembed', resp.text)
|
||||
self.assertIn('/api/oembed?url=', resp.text)
|
||||
self.assertIn('1141367104702038016', resp.text)
|
||||
|
|
@ -244,11 +245,15 @@ class OEmbedDiscoveryTest(BaseTestCase):
|
|||
def test_oembed_discovery_roundtrip(self):
|
||||
"""Fetch a tweet page, extract oEmbed URL, call it, verify response."""
|
||||
import re
|
||||
resp = requests.get('http://localhost:8080/elonmusk/status/1141367104702038016')
|
||||
from urllib.parse import urlparse
|
||||
resp = requests.get(f'{self.base_url}/elonmusk/status/1141367104702038016')
|
||||
match = re.search(
|
||||
r'type="application/json\+oembed"\s+href="([^"]*)"', resp.text)
|
||||
self.assertIsNotNone(match, "No oEmbed discovery link found in page")
|
||||
oembed_url = match.group(1).replace('&', '&')
|
||||
# Rewrite host to base_url in case cfg.hostname differs (e.g. CI)
|
||||
parsed = urlparse(oembed_url)
|
||||
oembed_url = f'{self.base_url}{parsed.path}?{parsed.query}'
|
||||
oembed_resp = requests.get(oembed_url)
|
||||
self.assertEqual(oembed_resp.status_code, 200)
|
||||
data = oembed_resp.json()
|
||||
|
|
|
|||
Loading…
Reference in a new issue