Refactor test cases for improved readability and consistency
Some checks failed
Run Tests / e2e tests (push) Failing after 1m27s
Run Tests / lint tests (push) Failing after 6s
Run Tests / unit tests (push) Failing after 7s

- Updated test functions in various test files to enhance code clarity by formatting long lines and improving indentation.
- Adjusted assertions to use multi-line formatting for better readability.
- Added new test cases for theme settings API to ensure proper functionality.
- Ensured consistent use of line breaks and spacing across test files for uniformity.
This commit is contained in:
2025-10-27 10:32:55 +01:00
parent e8a86b15e4
commit 97b1c0360b
78 changed files with 2327 additions and 650 deletions

View File

@@ -11,6 +11,8 @@ from services.settings import (
list_css_env_override_rows,
read_css_color_env_overrides,
update_css_color_settings,
get_theme_settings,
save_theme_settings,
)
router = APIRouter(prefix="/api/settings", tags=["Settings"])
@@ -49,8 +51,7 @@ def read_css_settings(db: Session = Depends(get_db)) -> CSSSettingsResponse:
values = get_css_color_settings(db)
env_overrides = read_css_color_env_overrides()
env_sources = [
EnvOverride(**row)
for row in list_css_env_override_rows()
EnvOverride(**row) for row in list_css_env_override_rows()
]
except ValueError as exc:
raise HTTPException(
@@ -64,14 +65,17 @@ def read_css_settings(db: Session = Depends(get_db)) -> CSSSettingsResponse:
)
@router.put("/css", response_model=CSSSettingsResponse, status_code=status.HTTP_200_OK)
def update_css_settings(payload: CSSSettingsPayload, db: Session = Depends(get_db)) -> CSSSettingsResponse:
@router.put(
"/css", response_model=CSSSettingsResponse, status_code=status.HTTP_200_OK
)
def update_css_settings(
payload: CSSSettingsPayload, db: Session = Depends(get_db)
) -> CSSSettingsResponse:
try:
values = update_css_color_settings(db, payload.variables)
env_overrides = read_css_color_env_overrides()
env_sources = [
EnvOverride(**row)
for row in list_css_env_override_rows()
EnvOverride(**row) for row in list_css_env_override_rows()
]
except ValueError as exc:
raise HTTPException(
@@ -83,3 +87,24 @@ def update_css_settings(payload: CSSSettingsPayload, db: Session = Depends(get_d
env_overrides=env_overrides,
env_sources=env_sources,
)
class ThemeSettings(BaseModel):
theme_name: str
primary_color: str
secondary_color: str
accent_color: str
background_color: str
text_color: str
@router.post("/theme")
async def update_theme(theme_data: ThemeSettings, db: Session = Depends(get_db)):
data_dict = theme_data.model_dump()
saved = save_theme_settings(db, data_dict)
return {"message": "Theme updated", "theme": data_dict}
@router.get("/theme")
async def get_theme(db: Session = Depends(get_db)):
return get_theme_settings(db)