Skip to content

Commit 662471b

Browse files
test: update test fixtures for unified stores configuration
- Update mock_stores fixture to use config.stores instead of config.object_storage - Update mock_object_storage fixture to configure stores.default and stores.local - Remove project_name from object_storage_config (now embedded in location path) - Simplify fixture by using unified stores API
1 parent 76d5f94 commit 662471b

File tree

1 file changed

+18
-34
lines changed

1 file changed

+18
-34
lines changed

tests/conftest.py

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -375,23 +375,20 @@ def stores_config(s3_creds, tmpdir_factory):
375375

376376
@pytest.fixture
377377
def mock_stores(stores_config):
378-
"""Configure object storage stores for tests using new object_storage system."""
378+
"""Configure stores for tests using unified stores system."""
379379
# Save original configuration
380-
og_project_name = dj.config.object_storage.project_name
381-
og_stores = dict(dj.config.object_storage.stores)
380+
og_stores = dict(dj.config.stores)
382381

383382
# Set test configuration
384-
dj.config.object_storage.project_name = "djtest"
385-
dj.config.object_storage.stores.clear()
383+
dj.config.stores.clear()
386384
for name, config in stores_config.items():
387-
dj.config.object_storage.stores[name] = config
385+
dj.config.stores[name] = config
388386

389387
yield
390388

391389
# Restore original configuration
392-
dj.config.object_storage.project_name = og_project_name
393-
dj.config.object_storage.stores.clear()
394-
dj.config.object_storage.stores.update(og_stores)
390+
dj.config.stores.clear()
391+
dj.config.stores.update(og_stores)
395392

396393

397394
@pytest.fixture
@@ -827,9 +824,10 @@ def trash(schema_any):
827824
@pytest.fixture
828825
def object_storage_config(tmpdir_factory):
829826
"""Create object storage configuration for testing."""
830-
location = str(tmpdir_factory.mktemp("object_storage"))
827+
base_location = str(tmpdir_factory.mktemp("object_storage"))
828+
# Location now includes project context
829+
location = f"{base_location}/test_project"
831830
return {
832-
"project_name": "test_project",
833831
"protocol": "file",
834832
"location": location,
835833
"token_length": 8,
@@ -838,37 +836,23 @@ def object_storage_config(tmpdir_factory):
838836

839837
@pytest.fixture
840838
def mock_object_storage(object_storage_config):
841-
"""Mock object storage configuration in datajoint config."""
839+
"""Mock object storage configuration in datajoint config using unified stores."""
842840
# Save original values
843-
original = {
844-
"project_name": dj.config.object_storage.project_name,
845-
"protocol": dj.config.object_storage.protocol,
846-
"location": dj.config.object_storage.location,
847-
"token_length": dj.config.object_storage.token_length,
848-
"stores": dict(dj.config.object_storage.stores),
849-
}
850-
851-
# Set test values
852-
dj.config.object_storage.project_name = object_storage_config["project_name"]
853-
dj.config.object_storage.protocol = object_storage_config["protocol"]
854-
dj.config.object_storage.location = object_storage_config["location"]
855-
dj.config.object_storage.token_length = object_storage_config.get("token_length", 8)
841+
original_stores = dict(dj.config.stores)
856842

857-
# Configure 'local' store using same location
858-
dj.config.object_storage.stores["local"] = {
859-
"protocol": "file",
843+
# Configure default store for tests
844+
dj.config.stores["default"] = "local"
845+
dj.config.stores["local"] = {
846+
"protocol": object_storage_config["protocol"],
860847
"location": object_storage_config["location"],
848+
"token_length": object_storage_config.get("token_length", 8),
861849
}
862850

863851
yield object_storage_config
864852

865853
# Restore original values
866-
dj.config.object_storage.project_name = original["project_name"]
867-
dj.config.object_storage.protocol = original["protocol"]
868-
dj.config.object_storage.location = original["location"]
869-
dj.config.object_storage.token_length = original["token_length"]
870-
dj.config.object_storage.stores.clear()
871-
dj.config.object_storage.stores.update(original["stores"])
854+
dj.config.stores.clear()
855+
dj.config.stores.update(original_stores)
872856

873857

874858
@pytest.fixture

0 commit comments

Comments
 (0)