Add end-to-end tests for parent item management
All checks were successful
Chore App Build, Test, and Push Docker Images / build-and-push (push) Successful in 3m31s
All checks were successful
Chore App Build, Test, and Push Docker Images / build-and-push (push) Successful in 3m31s
- Implement tests for creating, editing, and deleting chores, kindness acts, and penalties. - Add tests to verify conversion of default items to user items and restoration of system defaults upon deletion. - Ensure proper cancellation of creation and editing actions. - Create a comprehensive plan document outlining the test scenarios and expected behaviors.
This commit is contained in:
@@ -30,6 +30,7 @@ from db.db import (
|
||||
pending_reward_db, pending_confirmations_db, tracking_events_db,
|
||||
child_overrides_db, chore_schedules_db, task_extensions_db,
|
||||
)
|
||||
from db.default import initializeImages, createDefaultTasks, createDefaultRewards
|
||||
from api.utils import normalize_email
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -488,6 +489,11 @@ def e2e_seed():
|
||||
task_extensions_db.truncate()
|
||||
refresh_tokens_db.truncate()
|
||||
|
||||
# Recreate only baseline defaults for e2e runs.
|
||||
initializeImages()
|
||||
createDefaultTasks()
|
||||
createDefaultRewards()
|
||||
|
||||
norm_email = normalize_email(E2E_TEST_EMAIL)
|
||||
user = User(
|
||||
first_name='E2E',
|
||||
|
||||
@@ -26,6 +26,12 @@ def get_database_dir(db_env: str | None = None) -> str:
|
||||
env = (db_env or os.environ.get('DB_ENV', 'prod')).lower()
|
||||
return os.path.join(PROJECT_ROOT, get_base_data_dir(env), 'db')
|
||||
|
||||
def get_images_dir() -> str:
|
||||
"""
|
||||
Return the absolute directory path for storing images.
|
||||
"""
|
||||
return os.path.join(PROJECT_ROOT, get_base_data_dir(), 'images')
|
||||
|
||||
def get_user_image_dir(username: str | None) -> str:
|
||||
"""
|
||||
Return the absolute directory path for storing images for a specific user.
|
||||
|
||||
@@ -6,10 +6,14 @@ import os
|
||||
import shutil
|
||||
|
||||
from api.image_api import IMAGE_TYPE_ICON, IMAGE_TYPE_PROFILE
|
||||
from config.paths import get_images_dir
|
||||
from db.db import task_db, reward_db, image_db
|
||||
from models.image import Image
|
||||
from models.reward import Reward
|
||||
from models.task import Task
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def populate_default_data():
|
||||
@@ -124,7 +128,8 @@ def initializeImages():
|
||||
|
||||
"""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')
|
||||
default_img_dir = os.path.join(get_images_dir(), 'default')
|
||||
logger.info(f"Initializing images. Ensuring directory exists: {default_img_dir}")
|
||||
os.makedirs(default_img_dir, exist_ok=True)
|
||||
|
||||
# Step 2: Copy all image files from resources/images/ to data/images/default
|
||||
|
||||
Reference in New Issue
Block a user