Files
hpr-intro-stripper/tests/test_fetch.py
T
Lee Hanken 9917320640 hpr-intro-stripper: layered intro/outro cut-point detection and trimming
Fetches HPR's own metadata, audio, and official transcripts live; falls
back to local speech recognition (tiny model, matching HPR's own
hpr-get-and-transcribe.bash tooling) only when needed, and to
correlation against vendored reference clips or sibling episodes
otherwise. License-aware, resumable, and never guesses -- flags
anything it isn't confident about for manual review rather than
producing a plausible-looking wrong cut.
2026-11-22 10:36:07 +00:00

30 lines
1.1 KiB
Python

import unittest
from hpr_stripper import fetch
class TestErrorPageDetection(unittest.TestCase):
def test_rejects_html_404_page(self):
body = b"<html>\n<head><title>404 Not Found</title></head>\n<body>...</body></html>"
self.assertTrue(fetch._looks_like_error_page(body))
def test_rejects_s3_access_denied_xml(self):
body = (
b'<?xml version="1.0" encoding="UTF-8"?><Error><Code>AccessDenied</Code>'
b'<Message></Message><BucketName>hpr</BucketName></Error>'
)
self.assertTrue(fetch._looks_like_error_page(body))
def test_accepts_real_srt_content(self):
body = b"1\n00:00:00,000 --> 00:00:05,000\nThis is real subtitle text.\n"
self.assertFalse(fetch._looks_like_error_page(body))
def test_accepts_binary_audio_looking_data(self):
# A real audio file's first bytes are arbitrary binary, not markup.
body = bytes([0xFF, 0xFB, 0x90, 0x00]) + b"\x00" * 100
self.assertFalse(fetch._looks_like_error_page(body))
if __name__ == "__main__":
unittest.main()