39
39
display_tag_tooltip ,
40
40
parse_comment_tag ,
41
41
parse_subtag ,
42
+ remove_disabled_plugin_tags ,
42
43
script_variable_tag_names ,
43
44
)
44
45
from picard .tags .tagvar import (
@@ -59,6 +60,13 @@ def _translate_patch(s):
59
60
return f"_({ s } )"
60
61
61
62
63
+ class _config_patch ():
64
+ setting = {'enabled_plugins' : ['plugin_id' ]}
65
+
66
+ def __init__ (self ):
67
+ pass
68
+
69
+
62
70
class TagVarTest (PicardTestCase ):
63
71
def test_basic_properties (self ):
64
72
tv = TagVar ('name' )
@@ -132,6 +140,7 @@ def setUp(self):
132
140
is_file_info = True , is_hidden = True , is_script_variable = False )
133
141
self .tagvar_notes2 = TagVar ('notes2' , shortdesc = 'notes2_sd' , longdesc = 'notes2_ld' , is_file_info = True , is_from_mb = False )
134
142
self .tagvar_notes3 = TagVar ('notes3' , shortdesc = 'notes3_sd' , longdesc = 'notes3_ld' , is_from_mb = False )
143
+ self .tagvar_plugin = TagVar ('plugin' , shortdesc = 'plugin_sd' , longdesc = 'plugin_ld' , plugin_id = 'plugin_id' )
135
144
self .tagvar_everything = TagVar ('everything' , shortdesc = 'everything sd' , longdesc = 'everything ld.' ,
136
145
additionaldesc = 'Test additional description.' , is_preserved = True ,
137
146
is_script_variable = False , is_tag = False , is_calculated = True , is_file_info = True , is_from_mb = False ,
@@ -531,3 +540,23 @@ def test_links_completeness(self):
531
540
link = doc_link .link .strip ()
532
541
self .assertNotEqual (title , '' , f"Invalid link (missing title) in '{ str (tv )} ' tag" )
533
542
self .assertNotEqual (link , '' , f"Invalid link (missing URL) in '{ str (tv )} ' tag" )
543
+
544
+
545
+ class TagsPluginsTest (PicardTestCase ):
546
+ def setUp (self ):
547
+ self .tagvar_plugin_known = TagVar ('known' , shortdesc = 'known_sd' , plugin_id = 'plugin_id' )
548
+ self .tagvar_plugin_unknown = TagVar ('unknown' , shortdesc = 'unknown_sd' , plugin_id = 'unknown_plugin_id' )
549
+
550
+ def test_cleaning_plugin_var (self ):
551
+ tagvars = TagVars (
552
+ self .tagvar_plugin_known ,
553
+ self .tagvar_plugin_unknown ,
554
+ )
555
+ self .assertEqual (len (tagvars ), 2 )
556
+
557
+ with mock .patch ('picard.tags.get_config' , return_value = _config_patch ()):
558
+ with mock .patch ('picard.tags.ALL_TAGS' , tagvars ):
559
+ remove_disabled_plugin_tags ()
560
+ self .assertEqual (len (tagvars ), 1 )
561
+
562
+ self .assertEqual (tagvars [0 ], self .tagvar_plugin_known )
0 commit comments