import pytest import os import tomllib import tomli_w from pathlib import Path import sys # Ensure project root is in path sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) import ai_client import project_manager def test_credentials_error_mentions_deepseek(monkeypatch): """ Verify that the error message shown when credentials.toml is missing includes deepseek instructions. """ # Monkeypatch SLOP_CREDENTIALS to a non-existent file monkeypatch.setenv("SLOP_CREDENTIALS", "non_existent_credentials_file.toml") with pytest.raises(FileNotFoundError) as excinfo: ai_client._load_credentials() err_msg = str(excinfo.value) assert "[deepseek]" in err_msg assert "api_key" in err_msg def test_default_project_includes_reasoning_role() -> None: """ Verify that 'Reasoning' is included in the default discussion roles to support DeepSeek-R1 reasoning traces. """ proj = project_manager.default_project("test") roles = proj["discussion"]["roles"] assert "Reasoning" in roles def test_gui_providers_list() -> None: """ Check if 'deepseek' is in the GUI's provider list. """ import gui_2 assert "deepseek" in gui_2.PROVIDERS def test_deepseek_model_listing() -> None: """ Verify that list_models for deepseek returns expected models. """ models = ai_client.list_models("deepseek") assert "deepseek-chat" in models assert "deepseek-reasoner" in models def test_gui_provider_list_via_hooks(live_gui): """ Verify 'deepseek' is present in the GUI provider list using API hooks. """ from api_hook_client import ApiHookClient import time client = ApiHookClient() assert client.wait_for_server(timeout=10) # Attempt to set provider to deepseek to verify it's an allowed value client.set_value('current_provider', 'deepseek') time.sleep(0.5) assert client.get_value('current_provider') == 'deepseek'