Skip to content

Commit 21d03a7

Browse files
committed
Add test
1 parent 55ef006 commit 21d03a7

File tree

1 file changed

+65
-51
lines changed

1 file changed

+65
-51
lines changed

test/test_plugins.py

Lines changed: 65 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,20 @@ class RatingPlugin(plugins.BeetsPlugin):
9494
out = self.run_with_output("ls", "rating:3..5")
9595
assert "aaa" not in out
9696

97+
def test_multi_value_flex_field_type(self):
98+
class MultiValuePlugin(plugins.BeetsPlugin):
99+
item_types = {"multi_value": types.MULTI_VALUE_DSV}
100+
101+
self.register_plugin(MultiValuePlugin)
102+
103+
item = Item(path="apath", artist="aaa")
104+
item.multi_value = ["one", "two", "three"]
105+
item.add(self.lib)
106+
107+
out = self.run_with_output("ls", "-f", "$multi_value")
108+
delimiter = types.MULTI_VALUE_DSV.delimiter
109+
assert out == f"one{delimiter}two{delimiter}three\n"
110+
97111

98112
class ItemWriteTest(PluginLoaderTestCase):
99113
def setUp(self):
@@ -183,9 +197,9 @@ def __init__(self):
183197

184198
def import_task_created_event(self, session, task):
185199
if (
186-
isinstance(task, SingletonImportTask)
187-
or isinstance(task, SentinelImportTask)
188-
or isinstance(task, ArchiveImportTask)
200+
isinstance(task, SingletonImportTask)
201+
or isinstance(task, SentinelImportTask)
202+
or isinstance(task, ArchiveImportTask)
189203
):
190204
return task
191205

@@ -362,16 +376,16 @@ def return_choices(self, session, task):
362376
self.register_plugin(DummyPlugin)
363377
# Default options + extra choices by the plugin ('Foo', 'Bar')
364378
opts = (
365-
"Apply",
366-
"More candidates",
367-
"Skip",
368-
"Use as-is",
369-
"as Tracks",
370-
"Group albums",
371-
"Enter search",
372-
"enter Id",
373-
"aBort",
374-
) + ("Foo", "baR")
379+
"Apply",
380+
"More candidates",
381+
"Skip",
382+
"Use as-is",
383+
"as Tracks",
384+
"Group albums",
385+
"Enter search",
386+
"enter Id",
387+
"aBort",
388+
) + ("Foo", "baR")
375389

376390
self.importer.add_choice(Action.SKIP)
377391
self.importer.run()
@@ -398,14 +412,14 @@ def return_choices(self, session, task):
398412
self.register_plugin(DummyPlugin)
399413
# Default options + extra choices by the plugin ('Foo', 'Bar')
400414
opts = (
401-
"Apply",
402-
"More candidates",
403-
"Skip",
404-
"Use as-is",
405-
"Enter search",
406-
"enter Id",
407-
"aBort",
408-
) + ("Foo", "baR")
415+
"Apply",
416+
"More candidates",
417+
"Skip",
418+
"Use as-is",
419+
"Enter search",
420+
"enter Id",
421+
"aBort",
422+
) + ("Foo", "baR")
409423

410424
config["import"]["singletons"] = True
411425
self.importer.add_choice(Action.SKIP)
@@ -435,16 +449,16 @@ def return_choices(self, session, task):
435449
self.register_plugin(DummyPlugin)
436450
# Default options + not dupe extra choices by the plugin ('baZ')
437451
opts = (
438-
"Apply",
439-
"More candidates",
440-
"Skip",
441-
"Use as-is",
442-
"as Tracks",
443-
"Group albums",
444-
"Enter search",
445-
"enter Id",
446-
"aBort",
447-
) + ("baZ",)
452+
"Apply",
453+
"More candidates",
454+
"Skip",
455+
"Use as-is",
456+
"as Tracks",
457+
"Group albums",
458+
"Enter search",
459+
"enter Id",
460+
"aBort",
461+
) + ("baZ",)
448462
self.importer.add_choice(Action.SKIP)
449463
self.importer.run()
450464
self.mock_input_options.assert_called_once_with(
@@ -470,16 +484,16 @@ def foo(self, session, task):
470484
self.register_plugin(DummyPlugin)
471485
# Default options + extra choices by the plugin ('Foo', 'Bar')
472486
opts = (
473-
"Apply",
474-
"More candidates",
475-
"Skip",
476-
"Use as-is",
477-
"as Tracks",
478-
"Group albums",
479-
"Enter search",
480-
"enter Id",
481-
"aBort",
482-
) + ("Foo",)
487+
"Apply",
488+
"More candidates",
489+
"Skip",
490+
"Use as-is",
491+
"as Tracks",
492+
"Group albums",
493+
"Enter search",
494+
"enter Id",
495+
"aBort",
496+
) + ("Foo",)
483497

484498
# DummyPlugin.foo() should be called once
485499
with patch.object(DummyPlugin, "foo", autospec=True) as mock_foo:
@@ -512,16 +526,16 @@ def foo(self, session, task):
512526
self.register_plugin(DummyPlugin)
513527
# Default options + extra choices by the plugin ('Foo', 'Bar')
514528
opts = (
515-
"Apply",
516-
"More candidates",
517-
"Skip",
518-
"Use as-is",
519-
"as Tracks",
520-
"Group albums",
521-
"Enter search",
522-
"enter Id",
523-
"aBort",
524-
) + ("Foo",)
529+
"Apply",
530+
"More candidates",
531+
"Skip",
532+
"Use as-is",
533+
"as Tracks",
534+
"Group albums",
535+
"Enter search",
536+
"enter Id",
537+
"aBort",
538+
) + ("Foo",)
525539

526540
# DummyPlugin.foo() should be called once
527541
with helper.control_stdin("f\n"):

0 commit comments

Comments
 (0)