Пример #1
0
    def test_is_archive_file(self):
        self.assertTrue(RarArchive.is_archive_file('file.rar'))
        self.assertTrue(RarArchive.is_archive_file('file.r00'))
        self.assertTrue(RarArchive.is_archive_file('file.r01'))
        self.assertTrue(RarArchive.is_archive_file('file.R99'))
        self.assertTrue(RarArchive.is_archive_file('file.part42.rar'))

        self.assertFalse(RarArchive.is_archive_file('file'))
        self.assertFalse(RarArchive.is_archive_file('file.r'))
        self.assertFalse(RarArchive.is_archive_file('file.r100'))
        self.assertFalse(RarArchive.is_archive_file('file.rar.ext'))
Пример #2
0
    def test_is_archive_file(self):
        self.assertTrue(RarArchive.is_archive_file('file.rar'))
        self.assertTrue(RarArchive.is_archive_file('file.r00'))
        self.assertTrue(RarArchive.is_archive_file('file.r01'))
        self.assertTrue(RarArchive.is_archive_file('file.R99'))
        self.assertTrue(RarArchive.is_archive_file('file.part42.rar'))

        self.assertFalse(RarArchive.is_archive_file('file'))
        self.assertFalse(RarArchive.is_archive_file('file.r'))
        self.assertFalse(RarArchive.is_archive_file('file.r100'))
        self.assertFalse(RarArchive.is_archive_file('file.rar.ext'))
Пример #3
0
 def test__extract(self):
     system_commands = []
     def fake_system(cmd):
         system_commands.append(cmd)
     original_system = os.system
     os.system = fake_system
     
     filenames = ['archive.rar',
                  'archive.r00',
                  'archive.r01',
                  'archive.r02',]
     archive = RarArchive('archive', './path', filenames)
     self.assertTrue(archive._extract())
     self.assertEquals(system_commands, ['unrar e ./path/archive.rar'])
     os.system = original_system
Пример #4
0
    def test_remove(self):
        system_commands = []

        def fake_system(cmd):
            system_commands.append(cmd)

        original_system = os.system
        os.system = fake_system

        filenames = ['archive.rar',
                     'archive.r00',
                     'archive.r01',
                     'archive.r02']
        archive = RarArchive('archive', './path', filenames)
        archive.remove()
        self.assertEquals(system_commands,
                          ['rm -f ./path/archive.r00 ./path/archive.r01 '
                           './path/archive.r02 ./path/archive.rar'])
        os.system = original_system
Пример #5
0
    def test_remove(self):
        system_commands = []

        def fake_system(cmd):
            system_commands.append(cmd)

        original_system = os.system
        os.system = fake_system

        filenames = [
            'archive.rar', 'archive.r00', 'archive.r01', 'archive.r02'
        ]
        archive = RarArchive('archive', './path', filenames)
        archive.remove()
        self.assertEquals(system_commands, [
            'rm -f ./path/archive.r00 ./path/archive.r01 '
            './path/archive.r02 ./path/archive.rar'
        ])
        os.system = original_system