fix(settings): use timezone-aware datetime for current timestamp

fix(tests): normalize stored paths in library upsert test
This commit is contained in:
Will Miao
2025-10-03 20:59:47 +08:00
parent 3af8f151ac
commit 40d998a026
2 changed files with 4 additions and 3 deletions

View File

@@ -2,7 +2,7 @@ import copy
import json
import os
import logging
from datetime import datetime
from datetime import datetime, timezone
from typing import Any, Dict, Iterable, List, Mapping, Optional
from ..utils.settings_paths import ensure_settings_file
@@ -143,7 +143,7 @@ class SettingsManager:
self._save_settings()
def _current_timestamp(self) -> str:
return datetime.utcnow().replace(microsecond=0).isoformat() + "Z"
return datetime.now(timezone.utc).replace(microsecond=0).isoformat()
def _build_library_payload(
self,

View File

@@ -111,7 +111,8 @@ def test_upsert_library_creates_entry_and_activates(manager, tmp_path):
assert manager.get_active_library_name() == "studio"
libraries = manager.get_libraries()
stored_paths = libraries["studio"]["folder_paths"]["loras"]
assert str(lora_dir).replace(os.sep, "/") in stored_paths
normalized_stored_paths = [p.replace(os.sep, "/") for p in stored_paths]
assert str(lora_dir).replace(os.sep, "/") in normalized_stored_paths
def test_delete_library_switches_active(manager, tmp_path):