File: test_plugin_manager.py

package info (click to toggle)
quodlibet 4.7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,228 kB
  • sloc: python: 89,728; sh: 381; xml: 110; makefile: 91
file content (33 lines) | stat: -rw-r--r-- 1,128 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Copyright 2024 Nick Boultbee
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

import os

from quodlibet import get_base_dir, config
from quodlibet.plugins import PluginManager, PluginHandler
from tests.plugin import PLUGIN_DIRS


class EverythingHandler(PluginHandler):
    def plugin_handle(self, plugin):
        return True

    def plugin_enable(self, plugin):
        pass


def test_default_plugins_from_config():
    # Not the easiest route to test here
    config.init()
    folders = [os.path.join(get_base_dir(), "ext", kind) for kind in PLUGIN_DIRS]
    pm = PluginManager(folders)
    pm.rescan()
    # Need an active handler, otherwise no plugins will be enabled at all
    pm.register_handler(EverythingHandler())
    active = {p for p in pm.plugins if pm.enabled(p)}
    assert len(active) >= 2, f"Was expecting enough default plugins here: {active}"
    assert "Shuffle Playlist" in {a.name for a in active}