def test_save_wavpack_correction_file(self): config.setting['rename_files'] = True config.setting['move_files'] = False config.setting['ascii_filenames'] = False config.setting['windows_compatibility'] = False config.setting['dont_write_tags'] = True config.setting['preserve_timestamps'] = False config.setting['delete_empty_dirs'] = False config.setting['save_images_to_files'] = False config.setting['file_naming_format'] = '%title%' # Create dummy WavPack correction file source_file_wvc = self.filename + 'c' open(source_file_wvc, 'a').close() # Open file and rename it f = open_(self.filename) metadata = Metadata( {'title': 'renamed_' + os.path.basename(self.filename)}) self.assertTrue(os.path.isfile(self.filename)) target_file_wv = f._save_and_rename(self.filename, metadata) target_file_wvc = target_file_wv + 'c' # Register cleanups self.addCleanup(os.unlink, target_file_wv) self.addCleanup(os.unlink, target_file_wvc) # Check both the WavPack file and the correction file got moved self.assertFalse(os.path.isfile(self.filename)) self.assertFalse(os.path.isfile(source_file_wvc)) self.assertTrue(os.path.isfile(target_file_wv)) self.assertTrue(os.path.isfile(target_file_wvc))
def _save_with_wavpack_correction_file(self, source_file_wvc): # Create dummy WavPack correction file open(source_file_wvc, 'a').close() # Open file and rename it f = open_(self.filename) f._copy_loaded_metadata(f._load(self.filename)) f.metadata['title'] = 'renamed_' + os.path.basename(self.filename) self.assertTrue(os.path.isfile(self.filename)) target_file_wv = f._save_and_rename(self.filename, f.metadata) target_file_wvc = target_file_wv + 'c' # Register cleanups self.addCleanup(os.unlink, target_file_wv) self.addCleanup(os.unlink, target_file_wvc) return (target_file_wv, target_file_wvc)
def test_unchanged_metadata(self): self.set_config_values({ 'compare_ignore_tags': [], 'write_id3v23': True, }) file = open_(self.filename) file.orig_metadata = Metadata({ 'album': 'somealbum', 'title': 'sometitle', 'date': '2021', 'originaldate': '2021', 'artists': 'foo/bar', }) file.metadata = Metadata({ 'album': 'somealbum', 'title': 'sometitle', 'date': '2021-12', 'originaldate': '2021-12-04', 'artists': ['foo', 'bar'], }) file.state = File.NORMAL file.update(signal=False) self.assertEqual(file.similarity, 1.0) self.assertEqual(file.state, File.NORMAL)