Skip to content

Commit a926798

Browse files
committed
Fixed fixture scope and addressed linting
1 parent 54ec484 commit a926798

3 files changed

Lines changed: 15 additions & 10 deletions

File tree

integration/test_collections_sorting.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,40 @@
22
from integration.conftest import ClientFactory
33

44

5-
@pytest.fixture(scope="module")
6-
def client(client_factory: ClientFactory):
5+
@pytest.fixture
6+
def sorting_test_client(client_factory: ClientFactory):
77
client = client_factory()
88
client.collections.delete_all()
99
yield client
1010
client.collections.delete_all()
1111
client.close()
1212

1313

14-
def test_collections_list_all_sorting(client):
14+
def test_collections_list_all_sorting(sorting_test_client):
1515
"""Test that collections.list_all() returns collections sorted alphabetically by key."""
16+
17+
client = sorting_test_client
18+
1619
# Create collections with names in non-alphabetical order
1720
client.collections.create(name="TestCollectionC")
1821
client.collections.create(name="TestCollectionA")
1922
client.collections.create(name="TestCollectionB")
2023

2124
# Get all collections
2225
collections = client.collections.list_all()
23-
26+
2427
# Get the keys and filter only our test collections
2528
collection_keys = list(collections.keys())
2629
test_collections = [k for k in collection_keys if k.startswith("TestCollection")]
27-
30+
2831
# Verify they are in alphabetical order
2932
assert test_collections == sorted(test_collections)
30-
33+
3134
# Test with simple=False as well
3235
collections = client.collections.list_all(simple=False)
3336
collection_keys = list(collections.keys())
3437
test_collections = [k for k in collection_keys if k.startswith("TestCollection")]
3538
assert test_collections == sorted(test_collections)
36-
39+
3740
# Clean up
3841
client.collections.delete(["TestCollectionA", "TestCollectionB", "TestCollectionC"])

test/collection/test_collections_sorting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_collection_configs_from_json_sorting():
2424
):
2525
# Call the function
2626
result = _collection_configs_from_json(mock_schema)
27-
27+
2828
# Check that the keys are in alphabetical order
2929
assert list(result.keys()) == ["CollectionA", "CollectionB", "CollectionC"]
3030

@@ -47,6 +47,6 @@ def test_collection_configs_simple_from_json_sorting():
4747
):
4848
# Call the function
4949
result = _collection_configs_simple_from_json(mock_schema)
50-
50+
5151
# Check that the keys are in alphabetical order
5252
assert list(result.keys()) == ["CollectionA", "CollectionB", "CollectionC"]

weaviate/collections/classes/config_methods.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,9 @@ def _collection_config_from_json(schema: Dict[str, Any]) -> _CollectionConfig:
343343

344344

345345
def _collection_configs_from_json(schema: Dict[str, Any]) -> Dict[str, _CollectionConfig]:
346-
configs = {schema["class"]: _collection_config_from_json(schema) for schema in schema["classes"]}
346+
configs = {
347+
schema["class"]: _collection_config_from_json(schema) for schema in schema["classes"]
348+
}
347349
return dict(sorted(configs.items()))
348350

349351

0 commit comments

Comments
 (0)