reformatting
formatting_check / formatting_check (push) Failing after 3s
Python Test / test (.ps1, windows-latest, 3.9) (push) Has been cancelled
Python Test / test (.sh, macos-latest, 3.9) (push) Has been cancelled
Python Test / test (.sh, ubuntu-latest, 3.9) (push) Has been cancelled
formatting_check / formatting_check (push) Failing after 3s
Python Test / test (.ps1, windows-latest, 3.9) (push) Has been cancelled
Python Test / test (.sh, macos-latest, 3.9) (push) Has been cancelled
Python Test / test (.sh, ubuntu-latest, 3.9) (push) Has been cancelled
This commit is contained in:
@@ -3,13 +3,16 @@
|
||||
Test script to debug file extension detection issues
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from bdfr.resource import Resource
|
||||
|
||||
|
||||
def test_extension_detection():
|
||||
"""Test extension detection with various URL patterns"""
|
||||
|
||||
@@ -18,26 +21,20 @@ def test_extension_detection():
|
||||
("https://example.com/image.jpg", ".jpg"),
|
||||
("https://example.com/video.mp4", ".mp4"),
|
||||
("https://files.example.com/document.pdf", ".pdf"),
|
||||
|
||||
# URLs without extensions
|
||||
("https://example.com/api/data", None),
|
||||
("https://example.com/path/without/extension", None),
|
||||
|
||||
# URLs with query parameters
|
||||
("https://example.com/image.jpg?size=large", ".jpg"),
|
||||
("https://example.com/video.mp4?utm_source=test", ".mp4"),
|
||||
|
||||
# URLs with fragments
|
||||
("https://example.com/image.png#section", ".png"),
|
||||
|
||||
# Complex paths
|
||||
("https://imgur.com/a/gallery123", None),
|
||||
("https://reddit.com/r/test/abc123_def456_789", None),
|
||||
|
||||
# Edge cases that might cause weird names
|
||||
("https://example.com/L7SW9E~G", None),
|
||||
("https://example.com/temp/file", None),
|
||||
|
||||
# Reddit media URLs (the actual issue)
|
||||
("https://www.reddit.com/media?url=https%3A%2F%2Fi.redd.it%2Fr2mv10i4vkfd1.jpeg", ".jpeg"),
|
||||
("https://i.redd.it/r2mv10i4vkfd1.jpeg", ".jpeg"),
|
||||
@@ -60,5 +57,6 @@ def test_extension_detection():
|
||||
print(f"Match: {'YES' if resource.extension == expected else 'NO'}")
|
||||
print("-" * 40)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_extension_detection()
|
||||
test_extension_detection()
|
||||
|
||||
Reference in New Issue
Block a user