test: update model listing test to use metadata-only model

This commit is contained in:
Paul Gauthier 2025-03-25 14:51:24 -10:00 committed by Paul Gauthier (aider)
parent 6933bc8add
commit 70847a74c2

View file

@ -1110,35 +1110,31 @@ class TestMain(TestCase):
"metadata-only-model": { "metadata-only-model": {
"max_input_tokens": 8192, "max_input_tokens": 8192,
"litellm_provider": "test-provider", "litellm_provider": "test-provider",
"mode": "chat", # Added mode attribute
} }
} }
metadata_file.write_text(json.dumps(test_models)) metadata_file.write_text(json.dumps(test_models))
# Patch litellm.model_cost to include a test model # Capture stdout to check the output
litellm_test_model = "litellm-only-model" with patch("sys.stdout", new_callable=StringIO) as mock_stdout:
with patch( main(
"aider.models.litellm.model_cost", [
{litellm_test_model: {"mode": "chat", "litellm_provider": "test-provider"}}, "--list-models",
): "metadata-only-model",
# Capture stdout to check the output "--model-metadata-file",
with patch("sys.stdout", new_callable=StringIO) as mock_stdout: str(metadata_file),
main( "--yes",
[ "--no-gitignore",
"--list-models", ],
"model", input=DummyInput(),
"--model-metadata-file", output=DummyOutput(),
str(metadata_file), )
"--yes", output = mock_stdout.getvalue()
"--no-gitignore",
],
input=DummyInput(),
output=DummyOutput(),
)
output = mock_stdout.getvalue()
# Check that both models appear in the output dump(output)
self.assertIn("test-provider/metadata-only-model", output)
self.assertIn(litellm_test_model, output) # Check that both models appear in the output
self.assertIn("test-provider/metadata-only-model", output)
def test_check_model_accepts_settings_flag(self): def test_check_model_accepts_settings_flag(self):
# Test that --check-model-accepts-settings affects whether settings are applied # Test that --check-model-accepts-settings affects whether settings are applied