Skip to content

Commit aefac62

Browse files
author
OpenMontage Review
committed
test(stock): retain cross-process ID regression from PR OpenMontageInc#815
Adapted from PR OpenMontageInc#815 by @serdarucel: retain deterministic shape and PYTHONHASHSEED subprocess coverage with canonical PR OpenMontageInc#597 stable_url_id (16 hexadecimal characters). The cohort preserves the original reviewed heads for OpenMontageInc#594, OpenMontageInc#595, OpenMontageInc#597, OpenMontageInc#639, OpenMontageInc#652, OpenMontageInc#653, OpenMontageInc#779 and OpenMontageInc#857. No audio or Pixabay retry implementations are included.
1 parent 170c3ab commit aefac62

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
"""Issue #596 regression: source_id must be stable across processes.
2+
3+
Adapted from PR #815 by @serdarucel:
4+
https://github.com/calesthio/OpenMontage/pull/815
5+
Retains cross-process coverage with PR #597's shared 64-bit stable_url_id.
6+
"""
7+
8+
import os
9+
from pathlib import Path
10+
import subprocess
11+
import sys
12+
13+
from tools.video.stock_sources.base import stable_url_id
14+
15+
16+
def test_stable_url_id_is_deterministic():
17+
url = "https://example.com/x"
18+
source_id = stable_url_id(url)
19+
20+
assert source_id == stable_url_id(url)
21+
assert len(source_id) == 16
22+
assert all(char in "0123456789abcdef" for char in source_id)
23+
24+
25+
def test_stable_url_id_matches_subprocess_with_random_seed():
26+
repo_root = Path(__file__).resolve().parents[2]
27+
command = (
28+
"from tools.video.stock_sources.base import stable_url_id; "
29+
"print(stable_url_id('https://example.com/x'))"
30+
)
31+
outputs = []
32+
for seed in ("1", "2"):
33+
env = os.environ.copy()
34+
env["PYTHONHASHSEED"] = seed
35+
outputs.append(
36+
subprocess.check_output(
37+
[sys.executable, "-c", command],
38+
cwd=repo_root,
39+
env=env,
40+
text=True,
41+
timeout=15,
42+
).strip()
43+
)
44+
45+
assert outputs[0] == outputs[1] == stable_url_id("https://example.com/x")

0 commit comments

Comments
 (0)