43 lines · 1.1 KB
python
| 1 | from __future__ import annotations |
| 2 | |
| 3 | import sys |
| 4 | from pathlib import Path |
| 5 | |
| 6 | sys.path.insert(0, str(Path(__file__).resolve().parents[1])) |
| 7 | |
| 8 | from space_tape.render import format_ts, transcript_md |
| 9 | |
| 10 | |
| 11 | def test_format_ts() -> None: |
| 12 | assert format_ts(5.004) == "00:00:05" |
| 13 | assert format_ts(96) == "00:01:36" |
| 14 | assert format_ts(3723) == "01:02:03" |
| 15 | |
| 16 | |
| 17 | def test_transcript_keeps_x_url() -> None: |
| 18 | cues = [ |
| 19 | { |
| 20 | "start": 5.004, |
| 21 | "end": 7.003, |
| 22 | "speaker": "notpierce69", |
| 23 | "text": "Hey DJ, I don't think anyone else is gonna show up.", |
| 24 | } |
| 25 | ] |
| 26 | md = transcript_md( |
| 27 | cues, |
| 28 | source_url="https://x.com/i/spaces/1pKdRDlVbRrJW", |
| 29 | posted_url="https://x.com/notpierce69/status/2100117423017906497", |
| 30 | title="Explorer Initiation", |
| 31 | speakers=["notpierce69", "djay44444"], |
| 32 | ) |
| 33 | assert "https://x.com/i/spaces/1pKdRDlVbRrJW" in md |
| 34 | assert "https://x.com/notpierce69/status/2100117423017906497" in md |
| 35 | assert "**[00:00:05] @notpierce69**" in md |
| 36 | assert "@djay44444" in md |
| 37 | |
| 38 | |
| 39 | if __name__ == "__main__": |
| 40 | test_format_ts() |
| 41 | test_transcript_keeps_x_url() |
| 42 | print("ok") |