예제 #1
0
def test_theme_broken_meta(my_theme):
    (my_theme / "theme.json").open(mode="w", encoding="utf-8").write(
        str('{"titlewrong": xyz"bla"}'))

    assert theme_choices() == sorted([
        ("my_theme", "my_theme"),
    ])
def test_ui_theme_registration():
    var = config_variable_registry["ui_theme"]()
    assert var.domain() == ConfigDomainGUI
    assert var.group() == ConfigVariableGroupUserInterface

    valuespec = var.valuespec()
    assert isinstance(valuespec, DropdownChoice)
    assert valuespec.choices() == theme_choices()
예제 #3
0
def fixture_my_theme(theme_dirs, monkeypatch):
    theme_path = theme_dirs[0]
    my_dir = theme_path / "my_theme"
    my_dir.mkdir()
    (my_dir / "theme.json").open(mode="w", encoding="utf-8").write(
        str(json.dumps({"title": "Määh Theme :-)"})))

    # Update the theme choices after introducing a new theme here
    monkeypatch.setattr(theme, "theme_choices", theme_choices())

    return my_dir
예제 #4
0
def test_theme_choices_override(theme_dirs, my_theme):
    local_theme_path = theme_dirs[1]

    my_dir = local_theme_path / "my_theme"
    my_dir.mkdir()
    (my_dir / "theme.json").open(mode="w", encoding="utf-8").write(
        str(json.dumps({"title": "Fixed theme"})))

    assert theme_choices() == sorted([
        ("my_theme", "Fixed theme"),
    ])
예제 #5
0
def test_theme_choices_local_theme(theme_dirs, my_theme):
    local_theme_path = theme_dirs[1]

    my_dir = local_theme_path / "my_improved_theme"
    my_dir.mkdir()
    (my_dir / "theme.json").open(mode="w", encoding="utf-8").write(
        str(json.dumps({"title": "Määh Bettr Theme :-D"})))

    assert theme_choices() == sorted([
        ("my_theme", "Määh Theme :-)"),
        ("my_improved_theme", "Määh Bettr Theme :-D"),
    ])
예제 #6
0
    def page(self) -> AjaxPageResult:
        themes = [theme for theme, _title in theme_choices()]
        current_theme = theme.get()
        try:
            theme_index = themes.index(current_theme)
        except ValueError:
            raise MKUserError(None, _("Could not determine current theme."))

        if len(themes) == theme_index + 1:
            new_theme = themes[0]
        else:
            new_theme = themes[theme_index + 1]

        _set_user_attribute("ui_theme", new_theme)
        return {}
예제 #7
0
 def valuespec(self):
     return Alternative(
         title=_("User interface theme"),
         orientation="horizontal",
         elements=[
             FixedValue(
                 None,
                 title=_("Use the default theme"),
                 totext="",
             ),
             DropdownChoice(
                 title=_("Set custom theme"),
                 choices=theme_choices(),
             ),
         ],
     )
예제 #8
0
def test_theme_choices_normal(my_theme):
    assert theme_choices() == [("my_theme", "Määh Theme :-)")]
예제 #9
0
def test_theme_choices_empty(theme_dirs):
    assert theme_choices() == []