54 lines
1.1 KiB
Python
54 lines
1.1 KiB
Python
|
|
import pytest
|
||
|
|
import os
|
||
|
|
import tempfile
|
||
|
|
from unittest.mock import MagicMock
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.fixture
|
||
|
|
def temp_dir():
|
||
|
|
with tempfile.TemporaryDirectory() as tmpdir:
|
||
|
|
yield tmpdir
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.fixture
|
||
|
|
def mock_api_response():
|
||
|
|
return {
|
||
|
|
'choices': [
|
||
|
|
{
|
||
|
|
'message': {
|
||
|
|
'role': 'assistant',
|
||
|
|
'content': 'Test response'
|
||
|
|
}
|
||
|
|
}
|
||
|
|
],
|
||
|
|
'usage': {
|
||
|
|
'prompt_tokens': 10,
|
||
|
|
'completion_tokens': 5,
|
||
|
|
'total_tokens': 15
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.fixture
|
||
|
|
def mock_args():
|
||
|
|
args = MagicMock()
|
||
|
|
args.message = None
|
||
|
|
args.model = None
|
||
|
|
args.api_url = None
|
||
|
|
args.model_list_url = None
|
||
|
|
args.interactive = False
|
||
|
|
args.verbose = False
|
||
|
|
args.no_syntax = False
|
||
|
|
args.include_env = False
|
||
|
|
args.context = None
|
||
|
|
args.api_mode = False
|
||
|
|
return args
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.fixture
|
||
|
|
def sample_context_file(temp_dir):
|
||
|
|
context_path = os.path.join(temp_dir, '.rcontext.txt')
|
||
|
|
with open(context_path, 'w') as f:
|
||
|
|
f.write('Sample context content\n')
|
||
|
|
return context_path
|