Debian Codegraph @

test/plugins/test_ihate.py

raw
1 """Tests for the 'ihate' plugin"""
2
3 from beets import importer
4 from beets.library import Item
5 from beetsplug.ihate import IHatePlugin
6
7
8 class TestIHatePlugin:
9 def test_hate(self):
10 match_pattern = {}
11 test_item = Item(
12 genres=["TestGenre"], album="TestAlbum", artist="TestArtist"
13 )
14 task = importer.SingletonImportTask(None, test_item)
15
16 # Empty query should let it pass.
17 assert not IHatePlugin.do_i_hate_this(task, match_pattern)
18
19 # 1 query match.
20 match_pattern = ["artist:bad_artist", "artist:TestArtist"]
21 assert IHatePlugin.do_i_hate_this(task, match_pattern)
22
23 # 2 query matches, either should trigger.
24 match_pattern = ["album:test", "artist:testartist"]
25 assert IHatePlugin.do_i_hate_this(task, match_pattern)
26
27 # Query is blocked by AND clause.
28 match_pattern = ["album:notthis genres:testgenre"]
29 assert not IHatePlugin.do_i_hate_this(task, match_pattern)
30
31 # Both queries are blocked by AND clause with unmatched condition.
32 match_pattern = [
33 "album:notthis genres:testgenre",
34 "artist:testartist album:notthis",
35 ]
36 assert not IHatePlugin.do_i_hate_this(task, match_pattern)
37
38 # Only one query should fire.
39 match_pattern = [
40 "album:testalbum genres:testgenre",
41 "artist:testartist album:notthis",
42 ]
43 assert IHatePlugin.do_i_hate_this(task, match_pattern)