claude-dev-env 8.54.4 → 8.54.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/scripts/conftest.py
CHANGED
|
@@ -15,9 +15,32 @@ is in place by the time any test module runs its top-level imports.
|
|
|
15
15
|
|
|
16
16
|
from __future__ import annotations
|
|
17
17
|
|
|
18
|
+
import importlib
|
|
18
19
|
import sys
|
|
19
20
|
from pathlib import Path
|
|
20
21
|
|
|
22
|
+
import pytest
|
|
23
|
+
|
|
21
24
|
_scripts_directory = str(Path(__file__).resolve().parent)
|
|
22
25
|
if _scripts_directory not in sys.path:
|
|
23
26
|
sys.path.insert(0, _scripts_directory)
|
|
27
|
+
|
|
28
|
+
_live_broker_state_resolver = importlib.import_module("account_broker_support").broker_state_path
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@pytest.fixture(autouse=True)
|
|
32
|
+
def isolated_broker_state_path(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> Path:
|
|
33
|
+
"""Point every module's ``broker_state_path`` at a per-test file.
|
|
34
|
+
|
|
35
|
+
``account_broker`` binds ``broker_state_path`` by name from
|
|
36
|
+
``account_broker_support``, so each bound copy is replaced. A test that
|
|
37
|
+
patches only one copy still keeps the other off the home directory.
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
The isolated broker state path for this test.
|
|
41
|
+
"""
|
|
42
|
+
isolated_path = tmp_path / "account-broker" / "state.json"
|
|
43
|
+
for each_module in list(sys.modules.values()):
|
|
44
|
+
if getattr(each_module, "broker_state_path", None) is _live_broker_state_resolver:
|
|
45
|
+
monkeypatch.setattr(each_module, "broker_state_path", lambda: isolated_path)
|
|
46
|
+
return isolated_path
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""Broker state written during a test stays out of the home directory."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import subprocess
|
|
6
|
+
from datetime import datetime, timezone
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
import pytest
|
|
10
|
+
|
|
11
|
+
import account_broker
|
|
12
|
+
from dev_env_scripts_constants.account_broker_constants import (
|
|
13
|
+
Account,
|
|
14
|
+
Meters,
|
|
15
|
+
Product,
|
|
16
|
+
ProductAdapter,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_meter_cache_write_lands_outside_the_home_directory(
|
|
21
|
+
monkeypatch: pytest.MonkeyPatch,
|
|
22
|
+
tmp_path: Path,
|
|
23
|
+
isolated_broker_state_path: Path,
|
|
24
|
+
) -> None:
|
|
25
|
+
fake_home = tmp_path / "home"
|
|
26
|
+
monkeypatch.setenv("HOME", str(fake_home))
|
|
27
|
+
monkeypatch.setenv("USERPROFILE", str(fake_home))
|
|
28
|
+
account = Account(Product.CLAUDE, "only", tmp_path / "only")
|
|
29
|
+
reset_at = datetime(2026, 10, 5, tzinfo=timezone.utc)
|
|
30
|
+
adapter = ProductAdapter(
|
|
31
|
+
lambda: (account,),
|
|
32
|
+
lambda each_account: Meters(80, reset_at, 80, reset_at),
|
|
33
|
+
"CLAUDE_CONFIG_DIR",
|
|
34
|
+
("usage limit",),
|
|
35
|
+
)
|
|
36
|
+
monkeypatch.setitem(account_broker.all_product_adapters, Product.CLAUDE, adapter)
|
|
37
|
+
|
|
38
|
+
def runner(argv: list[str], **options: object) -> subprocess.CompletedProcess[str]:
|
|
39
|
+
return subprocess.CompletedProcess(argv, 0, "", "")
|
|
40
|
+
|
|
41
|
+
with account_broker.override_subprocess_runner(runner):
|
|
42
|
+
account_broker.run_job(Product.CLAUDE, ["claude"])
|
|
43
|
+
|
|
44
|
+
home_state_path = fake_home / ".claude" / "account-broker" / "state.json"
|
|
45
|
+
assert not home_state_path.exists()
|
|
46
|
+
assert f"claude:only:{account.home}" in isolated_broker_state_path.read_text(
|
|
47
|
+
encoding="utf-8"
|
|
48
|
+
)
|
|
@@ -1129,7 +1129,6 @@ def test_usage_limit_fallover_delivers_full_prompt_to_each_account(
|
|
|
1129
1129
|
return subprocess.CompletedProcess(argv, 0, FIXTURE_CLAUDE_STDOUT, "")
|
|
1130
1130
|
|
|
1131
1131
|
monkeypatch.setitem(account_broker.all_product_adapters, Product.CLAUDE, adapter)
|
|
1132
|
-
monkeypatch.setattr(account_broker, "broker_state_path", lambda: tmp_path / "state.json")
|
|
1133
1132
|
monkeypatch.setattr(
|
|
1134
1133
|
dispatcher,
|
|
1135
1134
|
"spawn_preflight_runner",
|