File: test_qltk__editutils.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 (79 lines) | stat: -rw-r--r-- 1,854 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# 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.

from tests import TestCase

from quodlibet.formats import DUMMY_SONG
from quodlibet.qltk._editutils import (
    FilterCheckButton,
    OverwriteWarning,
    WriteFailedError,
    FilterPluginBox,
    EditingPluginHandler,
)


class FCB(FilterCheckButton):
    _section = _key = _label = "foo"


class FCB2(FCB):
    _order = 1.0


class FCB3(FCB):
    _order = 1.2


class FCB4(FCB):
    _order = 1.3


class FCB5(FCB):
    _order = 1.3


class FCB1(FCB):
    _order = 1.4


class TFilterCheckButton(TestCase):
    def setUp(self):
        self.fcb1 = FCB1()
        self.fcb2 = FCB2()
        self.fcb3 = FCB3()
        self.fcb4 = FCB4()
        self.fcb5 = FCB5()

    def test_filter(self):
        self.assertRaises(NotImplementedError, self.fcb1.filter, "", "")

    def test_filter_list(self):
        self.assertRaises(NotImplementedError, self.fcb1.filter_list, [""], [""])

    def test_cmp(self):
        l = [self.fcb1, self.fcb2, self.fcb3, self.fcb4, self.fcb5]
        l.sort()
        self.assertEqual(l, [self.fcb2, self.fcb3, self.fcb4, self.fcb5, self.fcb1])

    def tearDown(self):
        for cb in [self.fcb1, self.fcb2, self.fcb3, self.fcb4, self.fcb5]:
            cb.destroy()


class TEditDialogs(TestCase):
    def test_overwrite(self):
        OverwriteWarning(None, DUMMY_SONG).destroy()

    def test_write_failed(self):
        WriteFailedError(None, DUMMY_SONG).destroy()


class TFilterPluginBox(TestCase):
    def test_main(self):
        handler = EditingPluginHandler()
        x = FilterPluginBox(handler)
        self.assertEqual(x.filters, [])
        x.destroy()