Rebrand sexp → sx across web platform (173 files)
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 11m37s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 11m37s
Rename all sexp directories, files, identifiers, and references to sx. artdag/ excluded (separate media processing DSL). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
74
shared/tests/test_sx_helpers.py
Normal file
74
shared/tests/test_sx_helpers.py
Normal file
@@ -0,0 +1,74 @@
|
||||
"""Tests for shared sx helper functions (call_url, get_asset_url, etc.)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from shared.sx.helpers import call_url, get_asset_url
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# call_url
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
class TestCallUrl:
|
||||
def test_callable_url_fn(self):
|
||||
ctx = {"blog_url": lambda path: f"https://blog.example.com{path}"}
|
||||
assert call_url(ctx, "blog_url", "/posts/") == "https://blog.example.com/posts/"
|
||||
|
||||
def test_callable_default_path(self):
|
||||
ctx = {"blog_url": lambda path: f"https://blog.example.com{path}"}
|
||||
assert call_url(ctx, "blog_url") == "https://blog.example.com/"
|
||||
|
||||
def test_string_url(self):
|
||||
ctx = {"blog_url": "https://blog.example.com"}
|
||||
assert call_url(ctx, "blog_url", "/posts/") == "https://blog.example.com/posts/"
|
||||
|
||||
def test_string_url_default_path(self):
|
||||
ctx = {"blog_url": "https://blog.example.com"}
|
||||
assert call_url(ctx, "blog_url") == "https://blog.example.com/"
|
||||
|
||||
def test_missing_key(self):
|
||||
ctx = {}
|
||||
assert call_url(ctx, "blog_url", "/x") == "/x"
|
||||
|
||||
def test_none_value(self):
|
||||
ctx = {"blog_url": None}
|
||||
assert call_url(ctx, "blog_url", "/x") == "/x"
|
||||
|
||||
def test_callable_with_empty_path(self):
|
||||
ctx = {"cart_url": lambda path: f"https://cart.example.com{path}"}
|
||||
assert call_url(ctx, "cart_url", "") == "https://cart.example.com"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# get_asset_url
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
class TestGetAssetUrl:
|
||||
def test_callable_asset_url(self):
|
||||
ctx = {"asset_url": lambda path: f"https://cdn.example.com/static{path}"}
|
||||
result = get_asset_url(ctx)
|
||||
# Should strip the trailing path component
|
||||
assert "cdn.example.com" in result
|
||||
|
||||
def test_string_asset_url(self):
|
||||
ctx = {"asset_url": "https://cdn.example.com/static"}
|
||||
assert get_asset_url(ctx) == "https://cdn.example.com/static"
|
||||
|
||||
def test_missing_asset_url(self):
|
||||
ctx = {}
|
||||
assert get_asset_url(ctx) == ""
|
||||
|
||||
def test_none_asset_url(self):
|
||||
ctx = {"asset_url": None}
|
||||
assert get_asset_url(ctx) == ""
|
||||
|
||||
def test_callable_returns_path_only(self):
|
||||
# au("") → "/static", rsplit("/",1)[0] → "" (splits on leading /)
|
||||
ctx = {"asset_url": lambda path: f"/static{path}"}
|
||||
result = get_asset_url(ctx)
|
||||
assert result == ""
|
||||
|
||||
def test_callable_with_nested_path(self):
|
||||
# au("") → "/assets/static", rsplit("/",1)[0] → "/assets"
|
||||
ctx = {"asset_url": lambda path: f"/assets/static{path}"}
|
||||
result = get_asset_url(ctx)
|
||||
assert result == "/assets"
|
||||
Reference in New Issue
Block a user