Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_cmd_performer_custom_join(self):
context = Metadata()
context['performer:guitar'] = 'Foo1'
context['performer:rhythm-guitar'] = 'Foo2'
context['performer:drums'] = 'Drummer'
result = self.parser.eval("$performer(guitar, / )", context=context)
performers = result.split(' / ')
self.assertIn('Foo1', performers)
self.assertIn('Foo2', performers)
self.assertEqual(2, len(performers))
def test_preserve_unchanged_tags(self):
metadata = Metadata(self.tags)
save_metadata(self.filename, metadata)
loaded_metadata = save_and_load_metadata(self.filename, Metadata())
for (key, value) in self.tags.items():
self.assertEqual(loaded_metadata[key], value, '%s: %r != %r' % (key, loaded_metadata[key], value))
def test_cmd_copymerge_nosource(self):
context = Metadata()
target = ["tag1", "tag2"]
context["target"] = target
self._eval_and_check_copymerge(context, target)
def test_comment_delete(self):
metadata = Metadata()
for (key, value) in self.tags.items():
metadata[key] = value
metadata['comment:bar'] = 'Foo'
original_metadata = save_and_load_metadata(self.filename, metadata)
metadata.delete('comment:bar')
new_metadata = save_and_load_metadata(self.filename, metadata)
self.assertIn('comment:foo', original_metadata)
self.assertIn('comment:bar', original_metadata)
self.assertIn('comment:foo', new_metadata)
self.assertNotIn('comment:bar', new_metadata)
def test_compare_tracknumber_difference(self):
m1 = Metadata()
m1["tracknumber"] = "1"
m2 = Metadata()
m2["tracknumber"] = "2"
self.assertEqual(m1.compare(m2), 0)
def _common_set_up(self, extra=None):
config.setting = settings.copy()
if extra is not None:
config.setting.update(extra)
def test_clear_existing_tags_on(self):
config.setting['clear_existing_tags'] = True
existing_metadata = Metadata({'artist': 'The Artist'})
save_metadata(self.filename, existing_metadata)
new_metadata = Metadata({'title': 'The Title'})
loaded_metadata = save_and_load_metadata(self.filename, new_metadata)
self.assertNotIn('artist', loaded_metadata)
self.assertEqual(new_metadata['title'], loaded_metadata['title'])
def test_invalid_rating(self):
filename = os.path.join('test', 'data', 'test-invalid-rating.ogg')
old_log_level = log.get_effective_level()
log.set_level(logging.ERROR)
metadata = load_metadata(filename)
log.set_level(old_log_level)
self.assertEqual(metadata["~rating"], "THERATING")
def test_upgrade_to_v1_0_0_final_0_A(self):
TextOption('setting', 'file_naming_format', '')
self.config.setting['va_file_naming_format'] = 'abc'
self.config.setting['use_va_format'] = True
self.assertIn('va_file_naming_format', self.config.setting)
self.assertIn('use_va_format', self.config.setting)
upgrade_to_v1_0_0_final_0(self.config, interactive=False, merge=True)
self.assertNotIn('va_file_naming_format', self.config.setting)
self.assertNotIn('use_va_format', self.config.setting)
self.assertIn('file_naming_format', self.config.setting)
def test_text_opt_set_empty(self):
TextOption("setting", "text_option", "abc")
# set option to ""
self.config.setting["text_option"] = ""
self.assertEqual(self.config.setting["text_option"], "")