Skip to content

Commit a191498

Browse files
Add e2e signed URL test gated on RUN_SIGNED_URL_TESTS
Why: the existing storage tests were all unconditionally skipped, leaving no executable coverage for create_signed_url. The new test exercises the real upload → sign → fetch flow against a live environment when RUN_SIGNED_URL_TESTS=true. The gate env var avoids the YEPCODE_* prefix so it does not collide with ConfigManager which forwards every YEPCODE_* var as a YepCodeApiConfig kwarg. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 92c0a54 commit a191498

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

tests/test_yepcode_storage.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
import os
2+
import tempfile
13
import time
4+
import uuid
25
from datetime import datetime, timezone
6+
from pathlib import Path
37

48
import pytest
59
import requests
@@ -31,6 +35,43 @@ def _parse_iso(value: str) -> float:
3135
return datetime.fromisoformat(value.replace("Z", "+00:00")).timestamp()
3236

3337

38+
@pytest.mark.skipif(
39+
os.getenv("RUN_SIGNED_URL_TESTS", "false").lower() != "true",
40+
reason="Set RUN_SIGNED_URL_TESTS=true to run signed URL end-to-end tests.",
41+
)
42+
def test_create_signed_url_e2e_matches_js_flow(storage):
43+
file_name = f"sdk-signed-url-test-{uuid.uuid4().hex}.txt"
44+
original_content = f"signed-url-test-content-{int(time.time() * 1000)}"
45+
46+
with tempfile.NamedTemporaryFile("w", delete=False, suffix=".txt") as temp_file:
47+
temp_file.write(original_content)
48+
local_file_path = Path(temp_file.name)
49+
50+
try:
51+
storage.upload(file_name, local_file_path.read_bytes())
52+
signed_url = storage.create_signed_url(file_name, expires_in_seconds=120)
53+
54+
assert isinstance(signed_url.url, str)
55+
assert len(signed_url.url) > 0
56+
assert signed_url.path == file_name
57+
assert _parse_iso(signed_url.expires_at) > time.time()
58+
59+
print(signed_url.url)
60+
61+
response = requests.get(signed_url.url, timeout=30)
62+
assert response.ok
63+
assert response.text == original_content
64+
finally:
65+
try:
66+
storage.delete(file_name)
67+
pass
68+
except Exception:
69+
pass
70+
71+
if local_file_path.exists():
72+
local_file_path.unlink()
73+
74+
3475
@pytest.mark.skip(reason="Requires the signed-urls endpoint deployed in the target environment")
3576
def test_create_signed_url_default_expiry(storage, uploaded_file):
3677
result = storage.create_signed_url(uploaded_file)

0 commit comments

Comments
 (0)