コード例 #1
0
    def test_dry_run(self):
        with helper.Capturing() as output:
            audiorename.execute('--dry-run', '--stats',
                                helper.get_testfile('mixed_formats'))

        self.assertTrue('Execution time:' in helper.join(output))
        self.assertTrue('Counter: move=3' in helper.join(output))
コード例 #2
0
    def test_delete(self):
        tmp1 = helper.copy_to_tmp('files', 'album.mp3')
        tmp2 = helper.copy_to_tmp('files', 'album.mp3')

        target = tempfile.mkdtemp()

        self.assertTrue(os.path.isfile(tmp1))
        self.assertTrue(os.path.isfile(tmp2))

        with helper.Capturing() as output1:
            audiorename.execute(
                '--delete',
                '--target',
                target,
                tmp1
            )

        self.assertTrue('Move' in helper.join(output1))
        self.assertFalse(os.path.isfile(tmp1))
        self.assertTrue(os.path.isfile(tmp2))

        with helper.Capturing() as output2:
            audiorename.execute(
                '--delete',
                '--target',
                target,
                tmp2
            )

        self.assertTrue('Delete' in helper.join(output2))
        self.assertFalse(os.path.isfile(tmp1))
        self.assertFalse(os.path.isfile(tmp2))
コード例 #3
0
    def test_compilation_already_renamed(self):
        with helper.Capturing():
            audiorename.execute(self.tmp_compilation)
        with helper.Capturing() as output:
            audiorename.execute(helper.dir_cwd + helper.path_compilation)

        self.assertTrue('Renamed' in helper.join(output))
コード例 #4
0
 def test_method_delete(self):
     tmp = helper.get_tmp_file_object('files', 'album.mp3')
     self.assertTrue(os.path.exists(tmp.abspath))
     with helper.Capturing() as output:
         self.action.delete(tmp)
     self.assertFalse(os.path.exists(tmp.abspath))
     self.assertTrue('Delete' in helper.join(output))
コード例 #5
0
 def test_delete_target(self):
     with helper.Capturing() as output:
         self.move(self.low_quality, '--delete')
         self.move(self.high_quality, '--delete')
     self.assertTrue(u'Delete […]test-file.mp3' in
                     helper.join(output))
     self.assertFalse(os.path.exists(self.high_quality))
     self.assertFalse(os.path.exists(self.low_quality))
コード例 #6
0
 def test_backup_source(self):
     with helper.Capturing() as output:
         self.move(self.high_quality, '--backup')
         self.move(self.low_quality, '--backup')
     self.assertTrue(u'Backup […]' + self.low_quality in
                     helper.join(output))
     self.assertFalse(os.path.exists(self.high_quality))
     self.assertFalse(os.path.exists(self.low_quality))
     backup_path = self.backup_path(os.path.basename(self.low_quality))
     self.assertTrue(os.path.exists(backup_path))
     os.remove(backup_path)
コード例 #7
0
 def test_backup_target(self):
     with helper.Capturing() as output:
         self.move(self.low_quality, '--backup')
         self.move(self.high_quality, '--backup')
     self.assertTrue(u'Backup […]test-file.mp3' in
                     helper.join(output))
     self.assertFalse(os.path.exists(self.high_quality))
     self.assertFalse(os.path.exists(self.low_quality))
     backup_path = self.backup_path('test-file.mp3')
     self.assertTrue(os.path.exists(backup_path))
     os.remove(backup_path)
コード例 #8
0
 def test_backup_folder_target(self):
     with helper.Capturing() as output:
         self.move(self.low_quality, *self.backup_args)
         self.move(self.high_quality, *self.backup_args)
     self.assertTrue(u'Backup […]test-file.mp3' in
                     helper.join(output))
     self.assertFalse(os.path.exists(self.high_quality))
     self.assertFalse(os.path.exists(self.low_quality))
     backup_file = os.path.join(self.backup_folder,
                                os.path.basename('test-file.mp3'))
     self.assertTrue(os.path.exists(backup_file))
     os.remove(backup_file)
コード例 #9
0
ファイル: test.py プロジェクト: fras2560/research
 def testCriticalAprox(self):
     # is_critical graphs
     g = nx.Graph()
     g.add_node(0)
     g = join(g, g)
     g = join(g, g)
     d = DalGraph(g)
     result = d.critical_aprox()
     self.assertEqual(result, True)
     g = make_wheel(6)
     d = DalGraph(g)
     result = d.critical_aprox()
     self.assertEqual(result, True)
     d = DalGraph(make_cycle(5))
     result = d.critical_aprox()
     self.assertEqual(result, True)
     # test non is_critical
     d = DalGraph(make_claw())
     result = d.critical_aprox()
     self.assertEqual(result, False)
     d = DalGraph(make_co_claw())
     result = d.critical_aprox()
     self.assertEqual(result, False)
コード例 #10
0
ファイル: test.py プロジェクト: fras2560/research
 def testKColor(self):
     g = DalGraph(make_cycle(3))
     c = g.k_color()
     self.assertEqual(3, c, "KColor: K3 case")
     g = DalGraph(make_cycle(4))
     c = g.k_color()
     self.assertEqual(None, c, "KColor: C4 case")
     g = DalGraph(make_wheel(6))
     c = g.k_color()
     self.assertEqual(4, c, "KColor: W6 case")
     c5 = make_cycle(5)
     c5_2 = make_cycle(5)
     c = join(c5,c5_2)
     g = DalGraph(c)
     c = g.k_color()
     self.assertEqual(c, 6, "KColor: C5 joined with a C5")
コード例 #11
0
    def test_verbose(self):
        tmp = helper.copy_to_tmp('files', 'album.mp3')

        target = tempfile.mkdtemp()

        with helper.Capturing() as output:
            audiorename.execute(
                '--copy',
                '--verbose',
                '--target',
                target,
                tmp
            )

        # '[Copy:       ] /tmp/tmpisugl3hp/album.mp3'
        # '            -> /tmp/tmpcwqxsfgx/t/the album artist/the
        # album_2001/4-02_full.mp3']

        self.assertTrue(target in helper.join(output))
コード例 #12
0
    def test_pass(self):
        tmp = helper.copy_to_tmp('classical', 'without_work.mp3')
        from audiorename.meta import Meta

        orig = Meta(tmp)
        orig.composer = None
        orig.composer_sort = None
        orig.save()
        orig = Meta(tmp)
        self.assertEqual(orig.composer_sort, None)
        self.assertEqual(orig.composer, None)
        self.assertEqual(orig.mb_workhierarchy_ids, None)
        self.assertEqual(orig.mb_workid, None)
        self.assertEqual(orig.work_hierarchy, None)
        self.assertEqual(orig.work, None)

        with helper.Capturing() as output:
            audiorename.execute('--enrich-metadata', '--no-rename', tmp)

        self.assertTrue('Enrich metadata' in helper.join(output))

        enriched = Meta(tmp)
        self.assertEqual(enriched.composer_sort, u'Wagner, Richard')
        self.assertEqual(enriched.composer, u'Richard Wagner')
        self.assertEqual(enriched.mb_workhierarchy_ids,
                         u'4d644732-9876-4b0d-9c2c-b6a738d6530e/'
                         u'73663bd3-392f-45a7-b4ff-e75c01f5926a/'
                         u'6b198406-4fbf-3d61-82db-0b7ef195a7fe')
        self.assertEqual(enriched.mb_workid,
                         u'6b198406-4fbf-3d61-82db-0b7ef195a7fe')
        self.assertEqual(enriched.work_hierarchy,
                         u'Die Meistersinger von Nürnberg, WWV 96 -> '
                         u'Die Meistersinger von Nürnberg, WWV 96: Akt I -> '
                         u'Die Meistersinger von Nürnberg, WWV 96: Akt I. '
                         u'Vorspiel')
        self.assertEqual(enriched.work,
                         u'Die Meistersinger von Nürnberg, WWV 96: Akt I. '
                         u'Vorspiel')
コード例 #13
0
    if not os.path.exists(dest_folder):
        os.mkdir(dest_folder)
    else:
        for file in os.listdir(dest_folder):
            os.remove(os.path.join(dest_folder, file))
    return dest_folder


start = time.time()

name = 'test.mp4'
names_routes = 'split-{}'.format(name)
file_name = 'join-{}'.format(name)

chunks = get_routes(names_routes)

folder = create_dir_or_clear(names_routes)

chunk_size = 256 * 1024

for chunk in chunks:
    url = 'http://localhost:8000/download/{}'.format(names_routes + '-' +
                                                     chunk)
    download_file(url, folder, chunk)

dest = dest_folder = os.path.join('download', 'chunks', name)

join(folder, dest, chunk_size)

end = time.time()
print(end - start)
コード例 #14
0
 def test_album(self):
     with helper.Capturing() as output:
         audiorename.execute(self.tmp_album)
     self.assertTrue('Exists' in helper.join(output))
コード例 #15
0
 def test_no_counts(self):
     tmp = tempfile.mkdtemp()
     with helper.Capturing() as output:
         audiorename.execute('--dry-run', '--stats', tmp)
     self.assertTrue('Counter: Nothing to count!' in helper.join(output))
     shutil.rmtree(tmp)
コード例 #16
0
 def test_compilation(self):
     with helper.Capturing() as output:
         audiorename.execute(self.tmp_compilation)
     self.assertTrue('Exists' in helper.join(output))
コード例 #17
0
from helper import join

chunk_size = 256*1024
name = 'ubuntu-18.04.2-desktop-amd64.iso'
source = './split/{}'.format(name)
dest = './join/{}'.format(name)

join(source,dest,chunk_size)