Exemple #1
0
    def testencode(self):
        """Validate that encode works correctly"""
        oggify = Oggify(self.src_dir, self.dst_dir, self.options,
                self.decoder, self.encoder)
        sev = oggify._encode.values()
        sev.sort()

        oggify.encode()
        self.assertEqual(sev, check_files(self.dst))
Exemple #2
0
    def testretag(self):
        """Validate that retag runs works correctly"""
        make_files(self.dst)
        time.sleep(1)
        make_files(self.src)
        self.assertTrue(compare_timestamps(self.src, self.dst, '>'))
        time.sleep(1)

        oggify = Oggify(self.src_dir, self.dst_dir, self.options,
                self.decoder, self.encoder)

        oggify.retag()
        self.assertTrue(compare_timestamps(self.src, self.dst, '<'))
Exemple #3
0
    def testpurge(self):
        """Validate that purge removes the correct files"""
        purge = ['/tmp/oggifytest/ogg/bob.ogg',
            '/tmp/oggifytest/ogg/somedirectories']
        self.dst += purge
        make_files(self.dst)

        oggify = Oggify(self.src_dir, self.dst_dir, self.options,
                self.decoder, self.encoder)

        oggify.purge()
        self.assertNotEqual(self.dst, check_files(self.dst))
        clean_dst = create_dst_list(first_src)
        self.assertEqual(clean_dst, check_files(clean_dst))
Exemple #4
0
    def testnewfileencode(self):
        """Validate that increment encode works correctly"""
        self.src += add_src
        make_files(add_src)
        make_files(self.dst)

        add_src.sort()
        add_dst = create_dst_list(add_src)
        self.dst += add_dst
        add_dst.sort()

        oggify = Oggify(self.src_dir, self.dst_dir, self.options,
                self.decoder, self.encoder)
        sev = oggify._encode.values()
        sev.sort()

        oggify.encode()
        self.assertEqual(sev, check_files(add_dst))
Exemple #5
0
    def testclean(self):
        """Validate that clean removes the correct files"""
        clean = [ re.sub(r'mp3', 'ogg', f, count=1)
                for f in create_dst_list(add_src, 'mp3') ]
        self.src += add_src
        make_files(add_src)
        self.dst += clean
        clean.sort()
        make_files(self.dst)

        oggify = Oggify(self.src_dir, self.dst_dir, self.options,
                self.decoder, self.encoder)
        ca = oggify._limited_purge
        ca.sort()

        oggify.clean()
        self.assertNotEqual(self.dst, check_files(self.dst))
        clean_dst = create_dst_list(first_src)
        self.assertEqual(clean_dst, check_files(clean_dst))
Exemple #6
0
    def testreencode(self):
        """Validate that existing files in dst are put in reencode"""
        make_files(self.dst)

        oggify = Oggify(self.src_dir, self.dst_dir, self.options,
                self.decoder, self.encoder, '/dev/null')
        rev = oggify._reencode.values()
        rev.sort()

        self.assertEqual(oggify._reencode_k, self.src)
        self.assertEqual(rev, self.dst)
Exemple #7
0
    def testpurge(self):
        """Validate that purge gets the correct files"""
        purge = ['/tmp/oggifytest/ogg/bob.ogg',
            '/tmp/oggifytest/ogg/somedirectories']
        purge.sort(reverse=True)
        self.dst += purge
        make_files(purge)

        oggify = Oggify(self.src_dir, self.dst_dir, self.options,
                self.decoder, self.encoder, '/dev/null')

        self.assertEqual(oggify._purge, purge)
Exemple #8
0
    def testencode(self):
        """Validate that on a new dst tree, only encode is present"""
        oggify = Oggify(self.src_dir, self.dst_dir, self.options, 
                self.decoder, self.encoder, '/dev/null')
        sev = oggify._encode.values()
        sev.sort()

        self.assertEqual(oggify._encode_k, self.src)
        self.assertEqual(sev, self.dst)
        self.assertEqual(oggify._reencode, {})
        self.assertEqual(oggify._purge, [])
        self.assertEqual(oggify._limited_purge, [])
Exemple #9
0
    def testclean(self):
        """Validate that clean gets the correct files"""
        clean = [ re.sub(r'mp3', 'ogg', f, count=1)
                for f in create_dst_list(add_src, 'mp3') ]
        self.src += add_src
        make_files(add_src)
        self.dst += clean
        clean.sort()
        make_files(self.dst)

        oggify = Oggify(self.src_dir, self.dst_dir, self.options,
                self.decoder, self.encoder, '/dev/null')
        ca = oggify._limited_purge
        ca.sort()

        self.assertEqual(ca, clean)
        self.dst += create_dst_list(add_src)
Exemple #10
0
    def testnewfileencode(self):
        """Validate that when files are added encode only has new files"""
        self.src += add_src
        make_files(add_src)
        make_files(self.dst)

        add_src.sort()
        add_dst = create_dst_list(add_src)
        self.dst += add_dst
        add_dst.sort()

        oggify = Oggify(self.src_dir, self.dst_dir, self.options,
                self.decoder, self.encoder, '/dev/null')
        sev = oggify._encode.values()
        sev.sort()

        self.assertEqual(oggify._encode_k, add_src)
        self.assertEqual(sev, add_dst)
Exemple #11
0
 def testnonemptydirremove(self):
     """Validate that a non-empty directory is deleted"""
     oggify = Oggify(self.src_dir, self.dst_dir, self.options,
             self.decoder, self.encoder, '/dev/null')
     oggify._rm_list([path.dirname(self.src[0])], True)
     self.assertEqual(path.exists(path.dirname(self.src[0])), False)