feat: v0.6.0 — collapse policy, session limiter, Claude Code provider, prune, browser auth, media downloads
This commit is contained in:
@@ -54,3 +54,65 @@ class TestValidateChatGPTToken:
|
||||
result = _validate_chatgpt_token("notajwttoken")
|
||||
assert any("does not look like a JWT" in r.message for r in caplog.records)
|
||||
assert result is None
|
||||
|
||||
|
||||
class TestSessionLimiterConfig:
|
||||
"""MAX_CONVERSATIONS_PER_RUN and REQUEST_DELAY parsing in load_config."""
|
||||
|
||||
def _load(self, monkeypatch, tmp_path, **env):
|
||||
from src.config import load_config
|
||||
monkeypatch.setenv("EXPORT_DIR", str(tmp_path / "exports"))
|
||||
monkeypatch.setenv("CACHE_DIR", str(tmp_path / "cache"))
|
||||
for key in (
|
||||
"MAX_CONVERSATIONS_PER_RUN",
|
||||
"REQUEST_DELAY",
|
||||
"EXPORTER_HIDDEN_CONTENT",
|
||||
"EXPORTER_DOWNLOAD_MEDIA",
|
||||
):
|
||||
monkeypatch.delenv(key, raising=False)
|
||||
for key, value in env.items():
|
||||
monkeypatch.setenv(key, value)
|
||||
return load_config()
|
||||
|
||||
def test_defaults(self, monkeypatch, tmp_path):
|
||||
cfg = self._load(monkeypatch, tmp_path)
|
||||
assert cfg.max_conversations is None
|
||||
assert cfg.request_delay == 1.0
|
||||
assert cfg.hidden_content == "placeholder"
|
||||
assert cfg.download_media == "images"
|
||||
|
||||
def test_download_media_valid(self, monkeypatch, tmp_path):
|
||||
cfg = self._load(monkeypatch, tmp_path, EXPORTER_DOWNLOAD_MEDIA="all")
|
||||
assert cfg.download_media == "all"
|
||||
|
||||
def test_download_media_invalid_raises(self, monkeypatch, tmp_path):
|
||||
from src.config import ConfigError
|
||||
with pytest.raises(ConfigError, match="EXPORTER_DOWNLOAD_MEDIA"):
|
||||
self._load(monkeypatch, tmp_path, EXPORTER_DOWNLOAD_MEDIA="sometimes")
|
||||
|
||||
def test_valid_values(self, monkeypatch, tmp_path):
|
||||
cfg = self._load(
|
||||
monkeypatch, tmp_path,
|
||||
MAX_CONVERSATIONS_PER_RUN="25", REQUEST_DELAY="0.5",
|
||||
)
|
||||
assert cfg.max_conversations == 25
|
||||
assert cfg.request_delay == 0.5
|
||||
|
||||
def test_zero_delay_allowed(self, monkeypatch, tmp_path):
|
||||
cfg = self._load(monkeypatch, tmp_path, REQUEST_DELAY="0")
|
||||
assert cfg.request_delay == 0.0
|
||||
|
||||
def test_non_integer_cap_raises(self, monkeypatch, tmp_path):
|
||||
from src.config import ConfigError
|
||||
with pytest.raises(ConfigError, match="MAX_CONVERSATIONS_PER_RUN"):
|
||||
self._load(monkeypatch, tmp_path, MAX_CONVERSATIONS_PER_RUN="lots")
|
||||
|
||||
def test_zero_cap_raises(self, monkeypatch, tmp_path):
|
||||
from src.config import ConfigError
|
||||
with pytest.raises(ConfigError, match="at least 1"):
|
||||
self._load(monkeypatch, tmp_path, MAX_CONVERSATIONS_PER_RUN="0")
|
||||
|
||||
def test_negative_delay_raises(self, monkeypatch, tmp_path):
|
||||
from src.config import ConfigError
|
||||
with pytest.raises(ConfigError, match="REQUEST_DELAY"):
|
||||
self._load(monkeypatch, tmp_path, REQUEST_DELAY="-1")
|
||||
|
||||
Reference in New Issue
Block a user