mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-02 10:45:00 +00:00
fixed test_models
This commit is contained in:
parent
23e6c4ee55
commit
a68d3d8a20
1 changed files with 7 additions and 14 deletions
|
@ -1,5 +1,5 @@
|
||||||
import unittest
|
import unittest
|
||||||
from unittest.mock import patch
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
from aider.models import Model, OpenRouterModel
|
from aider.models import Model, OpenRouterModel
|
||||||
|
|
||||||
|
@ -27,14 +27,9 @@ class TestModels(unittest.TestCase):
|
||||||
model = Model.create("gpt-4-32k-2123")
|
model = Model.create("gpt-4-32k-2123")
|
||||||
self.assertEqual(model.max_context_tokens, 32 * 1024)
|
self.assertEqual(model.max_context_tokens, 32 * 1024)
|
||||||
|
|
||||||
@patch("openai.resources.Models.list")
|
def test_openrouter_model_properties(self):
|
||||||
def test_openrouter_model_properties(self, mock_model_list):
|
client = MagicMock()
|
||||||
# import openai
|
client.models.list.return_value = {
|
||||||
|
|
||||||
# old_base = openai.api_base
|
|
||||||
# TODO: fixme
|
|
||||||
# openai.api_base = "https://openrouter.ai/api/v1"
|
|
||||||
mock_model_list.return_value = {
|
|
||||||
"data": [
|
"data": [
|
||||||
{
|
{
|
||||||
"id": "openai/gpt-4",
|
"id": "openai/gpt-4",
|
||||||
|
@ -44,17 +39,15 @@ class TestModels(unittest.TestCase):
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
mock_model_list.return_value = type(
|
client.models.list.return_value = type(
|
||||||
"", (), {"data": mock_model_list.return_value["data"]}
|
"", (), {"data": client.models.list.return_value["data"]}
|
||||||
)()
|
)()
|
||||||
|
|
||||||
model = OpenRouterModel("gpt-4")
|
model = OpenRouterModel(client, "gpt-4")
|
||||||
self.assertEqual(model.name, "openai/gpt-4")
|
self.assertEqual(model.name, "openai/gpt-4")
|
||||||
self.assertEqual(model.max_context_tokens, 8192)
|
self.assertEqual(model.max_context_tokens, 8192)
|
||||||
self.assertEqual(model.prompt_price, 0.06)
|
self.assertEqual(model.prompt_price, 0.06)
|
||||||
self.assertEqual(model.completion_price, 0.12)
|
self.assertEqual(model.completion_price, 0.12)
|
||||||
# TODO: fixme
|
|
||||||
# openai.api_base = old_base
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue