test(mcp): pin both shipped copies of a catalog icon to the same bytes

This commit is contained in:
mateo-berri 2026-09-24 19:36:05 -07:00
parent ceddd0a884
commit af5d4f1fbd

View file

@ -111,15 +111,26 @@ class TestMCPRegistryFile:
assert "ms-365-mcp-server" in entry["registry_url"]
def test_bundled_icons_exist(self, registry_path):
"""An icon served from the proxy's own assets must ship in the built dashboard or the card renders blank."""
"""An icon served from the proxy's own assets ships twice, as the built copy the wheel packages and as
the dashboard source copy every Docker image rebuilds from. Both must exist and match or a card goes blank."""
with open(registry_path, "r") as f:
data = json.load(f)
logos_dir: Final = os.path.join(os.path.dirname(registry_path), "_experimental", "out", "assets", "logos")
proxy_dir: Final = os.path.dirname(registry_path)
built_logos_dir: Final = os.path.join(proxy_dir, "_experimental", "out", "assets", "logos")
source_logos_dir: Final = os.path.join(
proxy_dir, "..", "..", "ui", "litellm-dashboard", "public", "assets", "logos"
)
bundled: Final = [s for s in data["servers"] if s.get("icon_url", "").startswith("/ui/assets/logos/")]
assert bundled, "at least one registry entry ships its own icon"
for server in bundled:
icon: Final = os.path.join(logos_dir, os.path.basename(server["icon_url"]))
assert os.path.isfile(icon), f"{server['name']} points at a missing icon {server['icon_url']}"
file_name: Final = os.path.basename(server["icon_url"])
built: Final = os.path.join(built_logos_dir, file_name)
source: Final = os.path.join(source_logos_dir, file_name)
assert os.path.isfile(built), f"{server['name']}: {server['icon_url']} missing from the built dashboard"
assert os.path.isfile(source), f"{server['name']}: {server['icon_url']} missing from the dashboard source"
with open(built, "rb") as built_file, open(source, "rb") as source_file:
same_bytes: Final = built_file.read() == source_file.read()
assert same_bytes, f"{server['name']}: built and source copies of {file_name} differ"
def test_env_vars_structure(self, registry_path):
with open(registry_path, "r") as f: