def test_shared_cover_art(self): # test what happens when 2 files with coverart share the same album. # In this case the first one we process should create the cover art # file and the next one should just skip cover art processing. src_path = resources.path(path.join('testdata', 'metadata', 'drm.m4v')) dest_paths = [] for x in range(3): new_filename = 'drm-%s.m4v' % x dest_path = path.join(self.tempdir, new_filename) shutil.copyfile(src_path, dest_path) dest_paths.append(dest_path) # process the first file result_1 = process_file(dest_paths[0], self.tempdir) self.assertEquals(result_1['cover_art'], path.join(self.tempdir, result_1['album'])) self.assert_(path.exists(result_1['cover_art'])) org_mtime = stat(result_1['cover_art']).st_mtime # process the rest, they should fill in the cover_art value, but # not rewrite the file for dup_path in dest_paths[1:]: results = process_file(dup_path, self.tempdir) self.assertEquals(results['cover_art'], result_1['cover_art']) self.assert_(path.exists(results['cover_art'])) self.assertEquals(stat(results['cover_art']).st_mtime, org_mtime)
def dynamic_test_case(self, filename, expected): # make all keys unicode #expected = dict((unicode(key), value) #for key, value in expected.iteritems()) filename = resources.path(path.join('testdata', 'metadata', filename)) results = process_file(filename, self.tempdir) # cover art nedes to be handled specially cover_art = expected.pop('cover_art') if cover_art: # cover art should be stored using the album name as its file correct_path = path.join(self.tempdir, results['album']) self.assertEquals(results.pop('cover_art'), correct_path) self.assertEquals(results.pop('created_cover_art'), True) else: self.assert_('cover_art' not in results) # for the rest, we just compare the dicts self.assertEquals(results, expected)
def dynamic_test_case(self, filename, expected): # make all keys unicode #expected = dict((unicode(key), value) #for key, value in expected.iteritems()) filename = resources.path(path.join('testdata', 'metadata', filename)) results = process_file(filename, self.tempdir) # cover art nedes to be handled specially cover_art = expected.pop('cover_art') if cover_art: # cover art should be stored using the album name as its file correct_path = path.join(self.tempdir, results['album']) self.assertEquals(results.pop('cover_art'), correct_path) self.assertEquals(results.pop('created_cover_art'), True) else: self.assert_('cover_art' not in results) if 'duration' in expected: expected_duration = expected.pop('duration') result_duration = results.pop('duration') self.assertClose(result_duration, expected_duration) # for the rest, we just compare the dicts self.assertDictEquals(results, expected)
def handle_mutagen_task(self, msg): return filetags.process_file(msg.source_path, msg.cover_art_directory)