91e75e620b
CI: cua-driver distro-compat matrix / debian:12 (glibc 2.36) (push) Has been cancelled
CI: SPDX Headers / Check SPDX headers (warn-only) (push) Has been cancelled
CD: Docs MCP Server / build (linux/amd64) (push) Has been cancelled
CD: Docs MCP Server / build (linux/arm64) (push) Has been cancelled
CD: Docs MCP Server / merge (push) Has been cancelled
CI: cua-driver distro-compat matrix / Resolve release version (push) Has been cancelled
CI: cua-driver distro-compat matrix / fedora:41 (glibc 2.40) (push) Has been cancelled
CI: cua-driver distro-compat matrix / rockylinux:9 (glibc 2.34) (push) Has been cancelled
CI: cua-driver distro-compat matrix / ubuntu:22.04 (glibc 2.35) (push) Has been cancelled
CI: cua-driver distro-compat matrix / ubuntu:24.04 (glibc 2.39) (push) Has been cancelled
CI: cua-driver distro-compat matrix / Distro compat summary (push) Has been cancelled
CI: Rust Linux unit / Rust Linux unit and compile (push) Has been cancelled
CI: Rust Windows unit / Rust Windows unit and compile (push) Has been cancelled
CI: Nix Linux Rust source / Nix / compositor build (push) Has been cancelled
CI: Nix Linux Rust source / Nix / driver package (push) Has been cancelled
CI: Nix Linux Rust source / Nix / Rust unit tests (push) Has been cancelled
31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
"""Unit tests for config and auth modules."""
|
|
|
|
from cua_sandbox._config import _global_config, configure, get_api_key, get_base_url
|
|
|
|
|
|
class TestConfig:
|
|
def setup_method(self):
|
|
_global_config.api_key = None
|
|
_global_config.base_url = "https://api.trycua.com"
|
|
|
|
def test_configure_api_key(self):
|
|
configure(api_key="sk-test-123")
|
|
assert get_api_key() == "sk-test-123"
|
|
|
|
def test_configure_base_url(self):
|
|
configure(base_url="http://localhost:9000")
|
|
assert get_base_url() == "http://localhost:9000"
|
|
|
|
def test_override_takes_priority(self):
|
|
configure(api_key="sk-global")
|
|
assert get_api_key("sk-override") == "sk-override"
|
|
|
|
def test_env_var_fallback(self, monkeypatch):
|
|
monkeypatch.setenv("CUA_API_KEY", "sk-env")
|
|
assert get_api_key() == "sk-env"
|
|
|
|
def test_configure_overrides_env(self, monkeypatch):
|
|
monkeypatch.setenv("CUA_API_KEY", "sk-env")
|
|
configure(api_key="sk-configured")
|
|
assert get_api_key() == "sk-configured"
|