~hristoast/mousikofidi

e380b82c6d26326acab16e8fd8405d8845d62951 — Hristos N. Triantafillou 8 months ago da707d7
Load custom css last, add tests for that and logo selection
2 files changed, 63 insertions(+), 7 deletions(-)

M mousikofidi/mousikofidi.py
M test_mousikofidi.py
M mousikofidi/mousikofidi.py => mousikofidi/mousikofidi.py +17 -7
@@ 1162,13 1162,23 @@ def select_css() -> tuple:
    except KeyError:
        theme = app.fidiConfig["config"]["theme"]

    css = [
        path + "css/normalize" + ext,
        path + "fa/css/fontawesome" + ext,
        path + "fa/css/solid" + ext,
        path + "css" + THEMES[theme] + ext,
        path + "css/fidi" + ext,
    ]
    if theme in THEMES.keys():
        css = [
            path + "css/normalize" + ext,
            path + "fa/css/fontawesome" + ext,
            path + "fa/css/solid" + ext,
            path + "css" + THEMES[theme] + ext,
            path + "css/fidi" + ext,
        ]
    else:
        css = [
            path + "css/normalize" + ext,
            path + "fa/css/fontawesome" + ext,
            path + "fa/css/solid" + ext,
            path + "css/fidi" + ext,
            theme,
        ]
        theme = "custom"

    if theme == "nes":
        css.append(path + "css/fidi-nes" + ext)

M test_mousikofidi.py => test_mousikofidi.py +46 -0
@@ 776,9 776,52 @@ def test_select_logo_dec_holiday():
    assert logo == "/fidi-dec.png"


def test_select_favicon_custom():
    c = {
        "config": {
            "favicon_path": "https://my.favicon.tld/mine.ico",
            "holidays": False,
            "logo_path": "/fidi.png",
        }
    }

    favicon = select_logo(c, "favicon_path")

    assert favicon == "https://my.favicon.tld/mine.ico"


def test_select_logo_custom():
    c = {
        "config": {
            "favicon_path": "/fidi.png",
            "logo_path": "https://my.logo.tld/logo.png",
            "holidays": False,
        }
    }

    logo = select_logo(c, "logo_path")

    assert logo == "https://my.logo.tld/logo.png"


def test_select_css_custom():
    app.fidiConfig["config"]["theme"] = "https://my.theme.tld/mytheme.css"
    with app.test_request_context("/"):
        css, theme = select_css()

    assert css[0] == "/css/normalize.min.css"
    assert css[1] == "/fa/css/fontawesome.min.css"
    assert css[2] == "/fa/css/solid.min.css"
    assert css[3] == "/css/fidi.min.css"
    assert css[4] == "https://my.theme.tld/mytheme.css"
    assert theme == "custom"


def test_select_css_light():
    app.fidiConfig["config"]["theme"] = "light"
    with app.test_request_context("/"):
        css, theme = select_css()

    assert css[0] == "/css/normalize.min.css"
    assert css[1] == "/fa/css/fontawesome.min.css"
    assert css[2] == "/fa/css/solid.min.css"


@@ 2420,6 2463,9 @@ def test_file_detail_real_ogg(client):
    )


# TODO: Test name truncating in file_dict()


def test_playlist_empty(client):
    url = "/queue"
    with app.app_context():