def test_sapcar_archive_file_from_file(self): """Test SAP CAR archive file object construction from file using the original name and a different one""" ff = SAPCARArchiveFile.from_file(self.test_filename) self.assertEqual(len(self.test_string), ff.size) self.assertEqual(self.test_filename, ff.filename) self.assertTrue(ff.check_checksum()) af = ff.open() self.assertEqual(self.test_string, af.read()) af.close() test_filename_new = "some_other_filename.txt" ff = SAPCARArchiveFile.from_file(self.test_filename, archive_filename=test_filename_new) self.assertEqual(len(self.test_string), ff.size) self.assertEqual(test_filename_new, ff.filename) self.assertTrue(ff.check_checksum()) af = ff.open() self.assertEqual(self.test_string, af.read()) af.close()
def test_sapcar_archive_file_200_to_201(self): """Test SAP CAR archive file object conversion from 2.00 to 2.01""" with open(data_filename("car200_test_string.sar"), "rb") as fd200: ar200 = SAPCARArchive(fd200, mode="r") ff200 = ar200.files[self.test_filename] ff201 = SAPCARArchiveFile.from_archive_file(ff200, SAPCAR_VERSION_201) self.assertEqual(ff200.size, ff201.size) self.assertEqual(ff200.filename, ff201.filename) self.assertEqual(ff200.timestamp, ff201.timestamp) self.assertEqual(ff200.permissions, ff201.permissions) self.assertEqual(ff200.checksum, ff201.checksum) af = ff201.open() self.assertEqual(self.test_string, af.read()) af.close()
def test_sapcar_archive_file_200_to_201(self): """Test SAP CAR archive file object conversion from 2.00 to 2.01""" with open(data_filename("car200_test_string.sar"), "rb") as fd200: ar200 = SAPCARArchive(fd200, mode="r") ff200 = ar200.files[self.test_filename] ff201 = SAPCARArchiveFile.from_archive_file( ff200, SAPCAR_VERSION_201) self.assertEqual(ff200.size, ff201.size) self.assertEqual(ff200.filename, ff201.filename) self.assertEqual(ff200.timestamp, ff201.timestamp) self.assertEqual(ff200.permissions, ff201.permissions) self.assertEqual(ff200.checksum, ff201.checksum) af = ff201.open() self.assertEqual(self.test_string, af.read()) af.close()