refactor: Clean up imports in currencies and users routes fix: Update theme settings saving logic and clean up test imports
57 lines
1.8 KiB
Python
57 lines
1.8 KiB
Python
from sqlalchemy.orm import Session
|
|
|
|
from services.settings import save_theme_settings, get_theme_settings
|
|
|
|
|
|
def test_save_theme_settings(db_session: Session):
|
|
theme_data = {
|
|
"theme_name": "dark",
|
|
"primary_color": "#000000",
|
|
"secondary_color": "#333333",
|
|
"accent_color": "#ff0000",
|
|
"background_color": "#1a1a1a",
|
|
"text_color": "#ffffff"
|
|
}
|
|
|
|
saved_setting = save_theme_settings(db_session, theme_data)
|
|
assert str(saved_setting.theme_name) == "dark"
|
|
assert str(saved_setting.primary_color) == "#000000"
|
|
|
|
|
|
def test_get_theme_settings(db_session: Session):
|
|
# Create a theme setting first
|
|
theme_data = {
|
|
"theme_name": "light",
|
|
"primary_color": "#ffffff",
|
|
"secondary_color": "#cccccc",
|
|
"accent_color": "#0000ff",
|
|
"background_color": "#f0f0f0",
|
|
"text_color": "#000000"
|
|
}
|
|
save_theme_settings(db_session, theme_data)
|
|
|
|
settings = get_theme_settings(db_session)
|
|
assert settings["theme_name"] == "light"
|
|
assert settings["primary_color"] == "#ffffff"
|
|
|
|
|
|
def test_theme_settings_api(api_client):
|
|
# Test API endpoint for saving theme settings
|
|
theme_data = {
|
|
"theme_name": "test_theme",
|
|
"primary_color": "#123456",
|
|
"secondary_color": "#789abc",
|
|
"accent_color": "#def012",
|
|
"background_color": "#345678",
|
|
"text_color": "#9abcde"
|
|
}
|
|
|
|
response = api_client.post("/api/settings/theme", json=theme_data)
|
|
assert response.status_code == 200
|
|
assert response.json()["theme"]["theme_name"] == "test_theme"
|
|
|
|
# Test API endpoint for getting theme settings
|
|
response = api_client.get("/api/settings/theme")
|
|
assert response.status_code == 200
|
|
assert response.json()["theme_name"] == "test_theme"
|