Initial commit.
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import pytest
|
||||
import os
|
||||
from pyr.core.config import PyrConfig, AIProvider
|
||||
|
||||
|
||||
def test_config_creation():
|
||||
config = PyrConfig()
|
||||
assert config.provider == AIProvider.OPENAI
|
||||
assert config.model == "gpt-4o-mini"
|
||||
assert config.verbose is True
|
||||
|
||||
|
||||
def test_config_with_overrides():
|
||||
config = PyrConfig(
|
||||
provider=AIProvider.ANTHROPIC,
|
||||
model="claude-3-5-haiku-20241022",
|
||||
temperature=0.5
|
||||
)
|
||||
assert config.provider == AIProvider.ANTHROPIC
|
||||
assert config.model == "claude-3-5-haiku-20241022"
|
||||
assert config.temperature == 0.5
|
||||
|
||||
|
||||
def test_config_urls():
|
||||
config = PyrConfig(provider=AIProvider.OPENAI)
|
||||
assert "openai.com" in config.get_completions_url()
|
||||
assert "openai.com" in config.get_models_url()
|
||||
|
||||
|
||||
def test_config_headers():
|
||||
config = PyrConfig(api_key="test-key", provider=AIProvider.OPENAI)
|
||||
headers = config.get_auth_headers()
|
||||
assert "Authorization" in headers
|
||||
assert headers["Authorization"] == "Bearer test-key"
|
||||
|
||||
|
||||
def test_anthropic_headers():
|
||||
config = PyrConfig(api_key="test-key", provider=AIProvider.ANTHROPIC)
|
||||
headers = config.get_auth_headers()
|
||||
assert "x-api-key" in headers
|
||||
assert headers["x-api-key"] == "test-key"
|
||||
|
||||
|
||||
def test_env_var_override(monkeypatch):
|
||||
monkeypatch.setenv("R_MODEL", "test-model")
|
||||
monkeypatch.setenv("R_PROVIDER", "anthropic")
|
||||
|
||||
config = PyrConfig()
|
||||
assert config.model == "test-model"
|
||||
assert config.provider == AIProvider.ANTHROPIC
|
||||
Reference in New Issue
Block a user