def test_new(self): self.filename = 'NewEntry' self.namesize = len(self.filename) self.attributes = 0 self.cluster = 0 self.filesize = 0 self.file = self.pack() de = DirectoryEntry.new_entry("NewEntry", None) self.assertEqual(self.file, de.pack()) with self.assertRaises(ValueError): DirectoryEntry.new_entry("This name is too long, like, so long, is does not fit in 42 chars", 0)
def test_pack(self): el = DirectoryEntryList(self.data, 0) self.assertEqual(self.data, el.pack()) de = DirectoryEntry.new_entry("New", None) el.append(de) self.assertIn(de.pack(), el.pack())
def test_append(self): el = DirectoryEntryList(self.data, 0) de = DirectoryEntry.new_entry("New", None) el.append(de) self.assertEqual(101, len(el.list())) self.assertIn(de, el.list())
def test_trailing_data(self): self.data += DirectoryEntry.new_entry("Entry", None).pack() * 5 self.assertEqual(100, len(DirectoryEntryList(self.data, 0)._l))
def test_missing_termination(self): self.data = DirectoryEntry.new_entry("Entry", None).pack() self.data *= 5 with self.assertRaises(SystemError): DirectoryEntryList(self.data, 0)
def setUp(self): self.data = b'' for i in range(0, 100): self.data += DirectoryEntry.new_entry("Entry {:02d}".format(i), None).pack() self.data += b'\xFF' * 64