Exemplo n.º 1
0
    def test_entry_ShortTypeOfEntry(self):
        entry = b'A       PY  \x00\x8a\x83\xa5]QaQ\x00' \
                b'\x00\x83\xa5]Q\xbd(\xa0\x00\x00\x00'
        entry = Entry(entry)
        self.assertEqual(entry.short_type, FileType.File)

        entry = b'DIR        \x10\x00G\xfbMPQPQ\x00\x00' \
                b'\xfbMPQ\x03\x00\x00\x00\x00\x00'
        entry = Entry(entry)
        self.assertEqual(entry.short_type, FileType.Directory)

        entry = b'\xff' * 32
        entry = Entry(entry)
        self.assertEqual(entry.short_type, FileType.Invalid)
Exemplo n.º 2
0
 def test_entry_LongEntryLetters(self):
     entry = b'\x01w\x00a\x00r\x00_\x00a\x00\x0f' \
             b'\x00Mn\x00d\x00_\x00p\x00i\x00e\x00\x00\x00c\x00e\x00'
     entry = Entry(entry)
     self.assertEqual(
         entry.long_entry_letters.decode('utf-16', errors='replace'),
         'war_and_piece')
Exemplo n.º 3
0
 def test_entry_LongNameFromShortEntry(self):
     entry = b'A       PY  \x00\x8a\x83\xa5]QaQ\x00' \
             b'\x00\x83\xa5]Q\xbd(\xa0\x00\x00\x00'
     entry = Entry(entry)
     self.assertTrue(entry.is_short_entry)
     self.assertRaises(ValueError, lambda: entry.long_dir_order)
     self.assertRaises(ValueError, lambda: entry.long_entry_letters)
Exemplo n.º 4
0
 def test_entry_ShortAttributesFromLongEntry(self):
     entry = b'\x01w\x00a\x00r\x00_\x00a\x00\x0f' \
             b'\x00Mn\x00d\x00_\x00p\x00i\x00e\x00\x00\x00c\x00e\x00'
     entry = Entry(entry)
     self.assertTrue(entry.is_long_entry)
     self.assertRaises(ValueError, lambda: entry.alias_name)
     self.assertRaises(ValueError, lambda: entry.file_size)
     self.assertRaises(ValueError, lambda: entry.short_type)
Exemplo n.º 5
0
 def test_entry_EntryIsFree(self):
     entry = b'\x00' * 32
     entry = Entry(entry)
     self.assertTrue(entry.is_free)
Exemplo n.º 6
0
 def test_entry_ShortEntryTestStr(self):
     entry = b'A       PY  \x00\x8a\x83\xa5]QaQ\x00' \
             b'\x00\x83\xa5]Q\xbd(\xa0\x00\x00\x00'
     entry = Entry(entry)
     self.assertEqual(str(entry), 'A.PY')
Exemplo n.º 7
0
 def test_entry_LongEntryTestStr(self):
     entry = b'\x01w\x00a\x00r\x00_\x00a\x00\x0f' \
             b'\x00Mn\x00d\x00_\x00p\x00i\x00e\x00\x00\x00c\x00e\x00'
     entry = Entry(entry)
     self.assertEqual(str(entry), 'long entry, war_and_piece')
Exemplo n.º 8
0
 def test_entry_NotEntryIsGiven(self):
     self.assertRaises(ValueError, lambda: Entry(b'abacaba'))