@@ -36,8 +36,8 @@ def _model_row(model_id: str, created=0) -> dict:
3636 }
3737
3838
39- def test_models_sorted_by_created_desc (httpx_mock , monkeypatch , tmp_path ):
40- """OpenRouter model list is sorted by created timestamp descending ."""
39+ def test_models_sorted_alphabetically (httpx_mock , monkeypatch , tmp_path ):
40+ """OpenRouter model list is sorted alphabetically by name ."""
4141 httpx_mock .add_response (
4242 json = {
4343 "data" : [
@@ -50,8 +50,7 @@ def test_models_sorted_by_created_desc(httpx_mock, monkeypatch, tmp_path):
5050 )
5151 engine = _make_engine (monkeypatch , tmp_path )
5252 models = engine .models
53- assert [model .id for model in models ] == ["newer" , "middle" , "older" ]
54- assert [model .created for model in models ] == [3000 , 2000 , 1000 ]
53+ assert [model .id for model in models ] == ["middle" , "newer" , "older" ]
5554 for m in models :
5655 assert m .extra_info ["metadata_catalog" ] == CATALOG_SOURCE_OPENROUTER_API
5756
@@ -71,11 +70,15 @@ def test_models_invalid_created_falls_back_to_zero(
7170 )
7271 engine = _make_engine (monkeypatch , tmp_path )
7372 models = engine .models
73+ # Alphabetical order: invalid-created < valid-created
7474 assert [model .id for model in models ] == [
75- "valid-created" ,
7675 "invalid-created" ,
76+ "valid-created" ,
7777 ]
78- assert [model .created for model in models ] == [42 , 0 ]
78+ assert {m .id : m .created for m in models } == {
79+ "valid-created" : 42 ,
80+ "invalid-created" : 0 ,
81+ }
7982
8083
8184def test_models_non_200_response_raises (httpx_mock , monkeypatch , tmp_path ):
0 commit comments