Add unit tests for LoginButton component with comprehensive coverage
All checks were successful
Gitea Actions Demo / build-and-push (push) Successful in 46s
All checks were successful
Gitea Actions Demo / build-and-push (push) Successful in 46s
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
# File: db/debug.py
|
||||
|
||||
from tinydb import Query
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from api.image_api import IMAGE_TYPE_ICON, IMAGE_TYPE_PROFILE
|
||||
from db.db import task_db, reward_db, image_db
|
||||
@@ -119,7 +121,22 @@ def createDefaultRewards():
|
||||
reward_db.insert(reward.to_dict())
|
||||
|
||||
def initializeImages():
|
||||
"""Initialize the image database with default images if empty."""
|
||||
|
||||
"""Initialize the image database with default images if empty, and copy images to data/images/default."""
|
||||
# Step 1: Create data/images/default directory if it doesn't exist
|
||||
default_img_dir = os.path.join(os.path.dirname(__file__), '../data/images/default')
|
||||
os.makedirs(default_img_dir, exist_ok=True)
|
||||
|
||||
# Step 2: Copy all image files from resources/images/ to data/images/default
|
||||
src_img_dir = os.path.join(os.path.dirname(__file__), '../resources/images')
|
||||
if os.path.exists(src_img_dir):
|
||||
for fname in os.listdir(src_img_dir):
|
||||
src_path = os.path.join(src_img_dir, fname)
|
||||
dst_path = os.path.join(default_img_dir, fname)
|
||||
if os.path.isfile(src_path):
|
||||
shutil.copy2(src_path, dst_path)
|
||||
|
||||
# Original DB initialization logic
|
||||
if len(image_db.all()) == 0:
|
||||
image_defs = [
|
||||
('boy01', IMAGE_TYPE_PROFILE, '.png', True),
|
||||
|
||||
Reference in New Issue
Block a user