Spaces:
Running
Running
File size: 2,427 Bytes
a9e27c0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | import json
import os
import shutil
import subprocess
from pathlib import Path
import pytest
from free_claude_code.cli.launchers.catalog_http import catalog_models_from_response
from free_claude_code.harnesses.codex import codex_config_args
from free_claude_code.harnesses.codex_model_catalog import (
build_codex_model_catalog,
)
from free_claude_code.runtime.codex_catalog import write_codex_model_catalog
from tests.harnesses.test_codex_model_catalog import _models_payload
def test_launcher_config_composes_with_persistent_codex_config(
tmp_path: Path,
) -> None:
codex_binary = shutil.which("codex")
if codex_binary is None:
pytest.skip("Codex CLI is not installed")
catalog_path = tmp_path / "codex-model-catalog.json"
write_codex_model_catalog(
catalog_path,
build_codex_model_catalog(
catalog_models_from_response(_models_payload("nvidia_nim/test-model"))
),
)
codex_home = tmp_path / "codex-home"
codex_home.mkdir()
(codex_home / "config.toml").write_text(
"\n".join(
(
'model_provider = "fcc"',
'model = "nvidia_nim/test-model"',
f"model_catalog_json = {json.dumps(str(catalog_path))}",
"",
"[model_providers.fcc]",
'name = "Free Claude Code"',
'base_url = "http://127.0.0.1:8082/v1"',
'wire_api = "responses"',
"",
"[model_providers.fcc.auth]",
'command = "fcc-codex"',
'args = ["--print-proxy-auth-token"]',
"",
)
),
encoding="utf-8",
)
codex_env = os.environ.copy()
for key in (
"CODEX_THREAD_ID",
"CODEX_INTERNAL_ORIGINATOR_OVERRIDE",
"CODEX_SHELL",
"CODEX_PERMISSION_PROFILE",
):
codex_env.pop(key, None)
codex_env["CODEX_HOME"] = str(codex_home)
result = subprocess.run(
[
codex_binary,
*codex_config_args(api_url="http://127.0.0.1:8082/v1"),
"debug",
"models",
],
capture_output=True,
check=False,
encoding="utf-8",
env=codex_env,
errors="replace",
text=True,
timeout=10,
)
assert result.returncode == 0, result.stderr
assert "nvidia_nim/test-model" in result.stdout
|