File: test_autobpm.py

package info (click to toggle)
beets 2.5.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,016 kB
  • sloc: python: 46,429; javascript: 8,018; xml: 334; sh: 261; makefile: 125
file content (46 lines) | stat: -rw-r--r-- 1,137 bytes parent folder | download | duplicates (2)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
import importlib.util
import os

import pytest

from beets.test.helper import ImportHelper, PluginMixin

github_ci = os.environ.get("GITHUB_ACTIONS") == "true"
if not github_ci and not importlib.util.find_spec("librosa"):
    pytest.skip("librosa isn't available", allow_module_level=True)


class TestAutoBPMPlugin(PluginMixin, ImportHelper):
    plugin = "autobpm"

    @pytest.fixture(scope="class", name="lib")
    def fixture_lib(self):
        self.setup_beets()

        yield self.lib

        self.teardown_beets()

    @pytest.fixture(scope="class")
    def item(self):
        return self.add_item_fixture()

    @pytest.fixture(scope="class")
    def importer(self, lib):
        self.import_media = []
        self.prepare_album_for_import(1)
        track = self.import_media[0]
        track.bpm = None
        track.save()
        return self.setup_importer(autotag=False)

    def test_command(self, lib, item):
        self.run_command("autobpm", lib=lib)

        item.load()
        assert item.bpm == 117

    def test_import(self, lib, importer):
        importer.run()

        assert lib.items().get().bpm == 117