def test_find_flac_files(self): with TemporaryDirectory() as tmp: for dir in ('/r1', '/r2/r21', '/r3'): if not isdir(tmp + dir): makedirs(tmp + dir) for file in ('/r1/f11.flac', '/r1/f12.flac', '/r2/r21/f21.flac'): open(tmp + file, 'w').close() liste_attendue = [tmp + '/r1/f11.flac', tmp + '/r1/f12.flac', tmp + '/r2/r21/f21.flac'] self.assertItemsEqual(liste_attendue, list(find_files(".flac", tmp))) self.assertItemsEqual(liste_attendue, list(find_files(".flac", tmp + "/r1", tmp + "/r2")))
def test_find_flac_files(self): with TemporaryDirectory() as tmp: for dir in ('/r1', '/r2/r21', '/r3'): if not isdir(tmp + dir): makedirs(tmp + dir) for file in ('/r1/f11.flac', '/r1/f12.flac', '/r2/r21/f21.flac'): open(tmp + file, 'w').close() liste_attendue = [ tmp + '/r1/f11.flac', tmp + '/r1/f12.flac', tmp + '/r2/r21/f21.flac' ] assert_equals(sorted(liste_attendue), sorted(list(find_files(".*\.flac", tmp)))) assert_equals( sorted(liste_attendue), sorted(list(find_files(".*\.flac", tmp + "/r1", tmp + "/r2"))))
def test_acceptance_one_file_with_embedded_cover(self): with TemporaryDirectory() as tmp: flac_file, mp3_file = self.init_files(tmp, embbed=True) transcode(flac_file, mp3_file) tag = eyed3.load(mp3_file).tag assert_equals(1, len(tag.images)) tmp_file_pattern = '%s.*\%s' % (CoverFile.tmp_prefix, CoverFile.tmp_suffix) assert_equals(0, len(set(find_files(tmp_file_pattern, tempfile.gettempdir()))))
def test_acceptance_one_file_with_embedded_cover(self): with TemporaryDirectory() as tmp: flac_file, mp3_file = self.init_files(tmp, embbed=True) transcode(flac_file, mp3_file) tag = eyed3.load(mp3_file).tag assert_equals(1, len(tag.images)) tmp_file_pattern = '%s.*\%s' % (CoverFile.tmp_prefix, CoverFile.tmp_suffix) assert_equals( 0, len(set(find_files(tmp_file_pattern, tempfile.gettempdir()))))
def test_convert_tree(self): with TemporaryDirectory() as tmp: for dir in ('/r1', '/r2/r21', '/r3', '/mp3'): if not isdir(tmp + dir): makedirs(tmp + dir) self.create_flac_file(join(tmp, 'r1/f11.flac')) self.create_flac_file(join(tmp, 'r1/f12.flac')) self.create_flac_file(join(tmp, 'r2/r21/f21.flac')) run(join(tmp, 'mp3'), tmp, tmp) expected = (join(tmp, mp3) for mp3 in ("mp3/r1/f11.mp3", "mp3/r1/f12.mp3", "mp3/r2/r21/f21.mp3")) actual = list(find_files(".mp3", tmp)) self.assertItemsEqual(actual, expected)
def test_convert_tree(self): with TemporaryDirectory() as tmp: for dir in ('/r1', '/r2/r21', '/r3', '/mp3'): if not isdir(tmp + dir): makedirs(tmp + dir) self.create_flac_file(join(tmp, 'r1/f11.flac')) self.create_flac_file(join(tmp, 'r1/f12.flac')) self.create_flac_file(join(tmp, 'r2/r21/f21.flac')) run(join(tmp, 'mp3'), tmp, tmp) expected = list( join(tmp, mp3) for mp3 in ("mp3/r1/f11.mp3", "mp3/r1/f12.mp3", "mp3/r2/r21/f21.mp3")) actual = list(find_files(".*.mp3", tmp)) assert_equals(sorted(actual), sorted(expected))