示例#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)
示例#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')
示例#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)
示例#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)
示例#5
0
 def test_entry_EntryIsFree(self):
     entry = b'\x00' * 32
     entry = Entry(entry)
     self.assertTrue(entry.is_free)
示例#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')
示例#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')
示例#8
0
 def test_entry_NotEntryIsGiven(self):
     self.assertRaises(ValueError, lambda: Entry(b'abacaba'))