Creator App Tests / PR Spam Gate (push) Skipped
Frontend Tests / PR Spam Gate (push) Skipped
NPM Format (website & console) / PR Spam Gate (push) Skipped
Pre-commit Checks / PR Spam Gate (push) Skipped
QwenPaw Creator Plugin Release / check-version (push) Canceled after 0s
QwenPaw Creator Plugin Release / upload-oss (push) Canceled after 0s
Tests / PR Spam Gate (push) Skipped
CodeQL / CodeQL (python) (push) Canceled after 0s
CodeQL / CodeQL (typescript) (push) Canceled after 0s
Creator App Tests / Creator Backend Tests (push) Canceled after 0s
Creator App Tests / Creator UI Build & Tests (push) Canceled after 0s
E2E Smoke Tests / Playwright UI Smoke (push) Canceled after 0s
Frontend Tests / Detect console changes (push) Canceled after 0s
NPM Format (website & console) / website format check (push) Canceled after 0s
NPM Format (website & console) / console format check (push) Canceled after 0s
Pre-commit Checks / Pre-commit (push) Canceled after 0s
QwenPaw Data Plugin Release / check-version (push) Canceled after 0s
Tests / Detect code changes (push) Canceled after 0s
Frontend Tests / Vitest Unit Tests (push) Canceled after 0s
Frontend Tests / Frontend Summary (push) Canceled after 0s
QwenPaw Data Plugin Release / upload-oss (push) Canceled after 0s
Tests / Maintainer Approval (push) Canceled after 0s
Tests / Unit Tests - py3.11 - macos-latest (push) Canceled after 0s
Tests / Unit Tests - py3.11 - ubuntu-latest (push) Canceled after 0s
Tests / Unit Tests - py3.13 - ubuntu-latest (push) Canceled after 0s
Tests / Unit Tests - py3.11 - windows-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - macos-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - ubuntu-latest (push) Canceled after 0s
Tests / Contract Tests - py3.13 - ubuntu-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - windows-latest (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - fallback (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p2 (push) Canceled after 0s
Tests / Coverage Report (push) Canceled after 0s
Tests / Test Summary (push) Canceled after 0s
57 lines
1.6 KiB
Python
57 lines
1.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Unit tests for ${VAR} env-reference parsing in legacy MCP migration."""
|
|
import pytest
|
|
|
|
from qwenpaw.drivers.adapters.env_ref import (
|
|
EnvTemplate,
|
|
env_alias,
|
|
env_ref,
|
|
parse_env_template,
|
|
)
|
|
|
|
|
|
def test_single_reference_with_prefix_yields_format_placeholder() -> None:
|
|
tpl = parse_env_template("Bearer ${API_KEY}")
|
|
assert tpl == EnvTemplate(format="Bearer {value}", var_names=("API_KEY",))
|
|
assert tpl.is_single
|
|
|
|
|
|
def test_pure_reference_uses_bare_placeholder() -> None:
|
|
tpl = parse_env_template("${API_KEY}")
|
|
assert tpl is not None
|
|
assert tpl.is_single
|
|
assert tpl.format == "{value}"
|
|
assert tpl.var_names == ("API_KEY",)
|
|
|
|
|
|
def test_multiple_references_are_not_single() -> None:
|
|
tpl = parse_env_template("${CLIENT}:${SECRET}")
|
|
assert tpl is not None
|
|
assert not tpl.is_single
|
|
assert tpl.var_names == ("CLIENT", "SECRET")
|
|
|
|
|
|
def test_plain_value_has_no_template() -> None:
|
|
assert parse_env_template("static-token") is None
|
|
|
|
|
|
@pytest.mark.parametrize("value", ["$PATH", "p@$$w0rd", "cost is $100", "$"])
|
|
def test_bare_dollar_is_not_a_reference(value: str) -> None:
|
|
assert parse_env_template(value) is None
|
|
|
|
|
|
def test_hyphenated_name_is_not_matched() -> None:
|
|
assert parse_env_template("${API-KEY}") is None
|
|
|
|
|
|
def test_leading_digit_name_is_not_matched() -> None:
|
|
assert parse_env_template("${1INVALID}") is None
|
|
|
|
|
|
def test_env_alias_is_deterministic_and_lowercased() -> None:
|
|
assert env_alias("API_KEY") == "env_api_key"
|
|
|
|
|
|
def test_env_ref_prefixes_store_env_scheme() -> None:
|
|
assert env_ref("API_KEY") == "env:API_KEY"
|