def test_001_extension_mapping_zip(self): zi = rozipinfo.ZipInfoRISCOS(filename='file.zip') self.checkRISCOS(zi, filename=b'file/zip', loadexec=build_loadexec(LOADADDR_BASEDATE, EXECADDR_BASEDATE, filetype=FILETYPE_ZIP), filetype=FILETYPE_ZIP, objtype=OBJTYPE_FILE, attr=ATTR_RW)
def test_002_extension_mapping_txt(self): zi = rozipinfo.ZipInfoRISCOS(filename='file.txt') self.checkRISCOS(zi, filename=b'file/txt', loadexec=build_loadexec(LOADADDR_BASEDATE, EXECADDR_BASEDATE, filetype=FILETYPE_TEXT), filetype=FILETYPE_TEXT, objtype=OBJTYPE_FILE, attr=ATTR_RW)
def test_053_directory_mapping_s_deep(self): zi = rozipinfo.ZipInfoRISCOS(filename='this/that/myapp/s/assembly') self.checkRISCOS(zi, filename=b'this.that.myapp.s.assembly', loadexec=build_loadexec(LOADADDR_BASEDATE, EXECADDR_BASEDATE, filetype=FILETYPE_TEXT), filetype=FILETYPE_TEXT, objtype=OBJTYPE_FILE, attr=ATTR_RW)
def test_060_directory_mapping_not_s(self): zi = rozipinfo.ZipInfoRISCOS(filename='nots/assembly') self.checkRISCOS(zi, filename=b'nots.assembly', loadexec=build_loadexec(LOADADDR_BASEDATE, EXECADDR_BASEDATE, filetype=FILETYPE_DATA), filetype=FILETYPE_DATA, objtype=OBJTYPE_FILE, attr=ATTR_RW)
def test_051_directory_mapping_c_subdir(self): zi = rozipinfo.ZipInfoRISCOS(filename='myapp/c/source') self.checkRISCOS(zi, filename=b'myapp.c.source', loadexec=build_loadexec(LOADADDR_BASEDATE, EXECADDR_BASEDATE, filetype=FILETYPE_TEXT), filetype=FILETYPE_TEXT, objtype=OBJTYPE_FILE, attr=ATTR_RW)
def test_065_externalattr_unixattr_r_____(self): zi = rozipinfo.ZipInfoRISCOS() zi.external_attr = 0o400 << 16 # r-------- self.checkRISCOS(zi, filename=b'NoName', loadexec=build_loadexec(LOADADDR_BASEDATE, EXECADDR_BASEDATE), filetype=FILETYPE_DATA, objtype=OBJTYPE_FILE, attr=ATTR_R)
def test_005_loadexec_suffix_untyped(self): zi = rozipinfo.ZipInfoRISCOS(filename='c/file,12345678,87654321', nfs_encoding=False) self.assertEqual(zi.filename, 'c/file,12345678,87654321') self.checkRISCOS(zi, filename=b'c.file,12345678,87654321', loadexec=build_loadexec(LOADADDR_BASEDATE, EXECADDR_BASEDATE, filetype=FILETYPE_TEXT), filetype=FILETYPE_TEXT, objtype=OBJTYPE_FILE, attr=ATTR_RW)
def test_020_datetime(self): zi = rozipinfo.ZipInfoRISCOS() zi.date_time = TESTDATE self.checkRISCOS(zi, filename=b'NoName', loadexec=build_loadexec(LOADADDR_TESTDATE, EXECADDR_TESTDATE), filetype=FILETYPE_DATA, objtype=OBJTYPE_FILE, attr=ATTR_RW)
def test_004_loadexec_suffix(self): zi = rozipinfo.ZipInfoRISCOS(filename='c/file,fffff93a,c7524201', nfs_encoding=False) # Note intentional + 1 (to match enabled case) self.assertEqual(zi.filename, 'c/file,fffff93a,c7524201') self.checkRISCOS(zi, filename=b'c.file,fffff93a,c7524201', loadexec=build_loadexec(LOADADDR_BASEDATE, EXECADDR_BASEDATE, filetype=FILETYPE_TEXT), filetype=FILETYPE_TEXT, objtype=OBJTYPE_FILE, attr=ATTR_RW)
def test_002_filetype_suffix_invalid(self): zi = rozipinfo.ZipInfoRISCOS(filename='file,fft', nfs_encoding=False) self.assertEqual(zi.filename, 'file,fft') self.checkRISCOS(zi, filename=b'file,fft', loadexec=build_loadexec(LOADADDR_BASEDATE, EXECADDR_BASEDATE, filetype=FILETYPE_DATA), filetype=FILETYPE_DATA, objtype=OBJTYPE_FILE, attr=ATTR_RW)
def test_003_filetype_suffix_before_pathname(self): zi = rozipinfo.ZipInfoRISCOS(filename='c/file,ff9', nfs_encoding=False) self.assertEqual(zi.filename, 'c/file,ff9') self.checkRISCOS(zi, filename=b'c.file,ff9', loadexec=build_loadexec(LOADADDR_BASEDATE, EXECADDR_BASEDATE, filetype=FILETYPE_TEXT), filetype=FILETYPE_TEXT, objtype=OBJTYPE_FILE, attr=ATTR_RW)
def test_060_externalattr_directory(self): zi = rozipinfo.ZipInfoRISCOS() zi.external_attr |= 16 self.checkRISCOS(zi, filename=b'NoName', loadexec=build_loadexec(LOADADDR_BASEDATE, EXECADDR_BASEDATE), filetype=FILETYPE_DIRECTORY, objtype=OBJTYPE_DIRECTORY, attr=ATTR_RW)
def test_040_internalattr_text(self): zi = rozipinfo.ZipInfoRISCOS() zi.internal_attr |= 1 self.checkRISCOS(zi, filename=b'NoName', loadexec=build_loadexec(LOADADDR_BASEDATE, EXECADDR_BASEDATE, filetype=FILETYPE_TEXT), filetype=FILETYPE_TEXT, objtype=OBJTYPE_FILE, attr=ATTR_RW)
def test_061_externalattr_readonly(self): zi = rozipinfo.ZipInfoRISCOS() zi.external_attr |= 1 self.checkRISCOS(zi, filename=b'NoName', loadexec=build_loadexec(LOADADDR_BASEDATE, EXECADDR_BASEDATE), filetype=FILETYPE_DATA, objtype=OBJTYPE_FILE, attr=ATTR_R)
def test_001_filename(self): zi = rozipinfo.ZipInfoRISCOS() zi.filename = "another-name" self.checkRISCOS(zi, filename=b'another-name', loadexec=build_loadexec(LOADADDR_BASEDATE, EXECADDR_BASEDATE), filetype=FILETYPE_DATA, objtype=OBJTYPE_FILE, attr=ATTR_RW)
def test_002_filetype_suffix_invalid(self): zi = rozipinfo.ZipInfoRISCOS(filename='file,fft') self.assertEqual(zi.filename, 'file,fft') self.checkRISCOS(zi, filename=b'file,fft', loadexec=build_loadexec(LOADADDR_BASEDATE, EXECADDR_BASEDATE, filetype=FILETYPE_DATA), filetype=FILETYPE_DATA, objtype=OBJTYPE_FILE, attr=ATTR_RW) self.assertEqual(zi.extra, b'', 'Should be no extra field when using NFS encoding')
def test_105_toggle_loadexec_suffix_untyped(self): zi = rozipinfo.ZipInfoRISCOS(filename='c/file,12345678,87654321') zi.nfs_encoding = False self.assertEqual(zi.filename, 'c/file') self.checkRISCOS(zi, filename=b'c.file', loadexec=build_loadexec(0x12345678, 0x87654321), filetype=-1, objtype=OBJTYPE_FILE, attr=ATTR_RW)
def test_005_loadexec_suffix_untyped(self): zi = rozipinfo.ZipInfoRISCOS(filename='c/file,12345678,87654321') self.assertEqual(zi.filename, 'c/file,12345678,87654321') self.checkRISCOS(zi, filename=b'c.file', loadexec=build_loadexec(0x12345678, 0x87654321), filetype=-1, objtype=OBJTYPE_FILE, attr=ATTR_RW) self.assertEqual(zi.extra, b'', 'Should be no extra field when using NFS encoding')
def test_004_loadexec_suffix(self): zi = rozipinfo.ZipInfoRISCOS(filename='c/file,fffff93a,c7524201') # Note intentional + 1 to check it's real self.assertEqual(zi.filename, 'c/file,fffff93a,c7524201') self.checkRISCOS(zi, filename=b'c.file', loadexec=build_loadexec(LOADADDR_BASEDATE, EXECADDR_BASEDATE + 1, filetype=FILETYPE_SPRITE), filetype=FILETYPE_SPRITE, objtype=OBJTYPE_FILE, attr=ATTR_RW) self.assertEqual(zi.extra, b'', 'Should be no extra field when using NFS encoding')
def test_004_zipinfo(self): # Check that it works when given a zipinfo original = zipfile.ZipInfo(filename='myfile', date_time=TESTDATE) zi = rozipinfo.ZipInfoRISCOS(zipinfo=original) self.checkRISCOS(zi, filename=original.filename.encode(zi.filename_encoding_name), loadexec=build_loadexec(LOADADDR_TESTDATE, EXECADDR_TESTDATE), filetype=FILETYPE_DATA, objtype=OBJTYPE_FILE, attr=ATTR_RW)
def test_010_directory(self): # Check that it works when given a filename original = zipfile.ZipInfo(filename='directory/') zi = rozipinfo.ZipInfoRISCOS(filename='directory/') self.checkRISCOS(zi, filename=b'directory', loadexec=build_loadexec(LOADADDR_BASEDATE, EXECADDR_BASEDATE), filetype=FILETYPE_DATA, objtype=OBJTYPE_FILE, attr=ATTR_RW)
def test_003_filetype_suffix_before_pathname(self): zi = rozipinfo.ZipInfoRISCOS(filename='c/file,ff9') self.assertEqual(zi.filename, 'c/file,ff9') self.checkRISCOS(zi, filename=b'c.file', loadexec=build_loadexec(LOADADDR_BASEDATE, EXECADDR_BASEDATE, filetype=FILETYPE_SPRITE), filetype=FILETYPE_SPRITE, objtype=OBJTYPE_FILE, attr=ATTR_RW) self.assertEqual(zi.extra, b'', 'Should be no extra field when using NFS encoding')
def test_101_toggle_filetype_suffix(self): zi = rozipinfo.ZipInfoRISCOS(filename='file,ff9') zi.nfs_encoding = False self.assertEqual(zi.filename, 'file') self.checkRISCOS(zi, filename=b'file', loadexec=build_loadexec(LOADADDR_BASEDATE, EXECADDR_BASEDATE, filetype=FILETYPE_SPRITE), filetype=FILETYPE_SPRITE, objtype=OBJTYPE_FILE, attr=ATTR_RW)
def test_001_filename(self): zi = rozipinfo.ZipInfoRISCOS() zi.riscos_filename = b"myfile" self.assertEqual(zi.filename, 'myfile') self.checkRISCOS(zi, filename=b'myfile', loadexec=build_loadexec(LOADADDR_BASEDATE, EXECADDR_BASEDATE), filetype=FILETYPE_DATA, objtype=OBJTYPE_FILE, attr=ATTR_RW)
def test_104_toggle_loadexec_suffix(self): zi = rozipinfo.ZipInfoRISCOS(filename='c/file,fffff93a,c7524201') # Note intentional + 1 to check it's real zi.nfs_encoding = False self.assertEqual(zi.filename, 'c/file') self.checkRISCOS(zi, filename=b'c.file', loadexec=build_loadexec(LOADADDR_BASEDATE, EXECADDR_BASEDATE + 1, filetype=FILETYPE_SPRITE), filetype=FILETYPE_SPRITE, objtype=OBJTYPE_FILE, attr=ATTR_RW)
def test_020_filetype(self): zi = rozipinfo.ZipInfoRISCOS() zi.riscos_filetype = FILETYPE_SPRITE self.assertEqual(zi.filename, 'NoName,ff9') self.assertFalse(bool(zi.internal_attr & 1), "Check for internal text flag") self.checkRISCOS(zi, filename=b'NoName', loadexec=build_loadexec(LOADADDR_BASEDATE, EXECADDR_BASEDATE, filetype=FILETYPE_SPRITE), filetype=FILETYPE_SPRITE, objtype=OBJTYPE_FILE, attr=ATTR_RW)
def test_001_empty(self): # Check that it works as when given nothing original = zipfile.ZipInfo() zi = rozipinfo.ZipInfoRISCOS() self.assertIsNotNone(zi) self.checkRISCOS(zi, filename=original.filename.encode(zi.filename_encoding_name), loadexec=build_loadexec(LOADADDR_BASEDATE, EXECADDR_BASEDATE), filetype=FILETYPE_DATA, objtype=OBJTYPE_FILE, attr=ATTR_RW)
def test_010_directory(self): # Check that it works when given a filename original = zipfile.ZipInfo(filename='directory/') zi = rozipinfo.ZipInfoRISCOS(filename='directory/') self.assertIsNotNone(zi) self.assertEqual(zi.filename, original.filename) self.assertEqual(zi.date_time, original.date_time) self.assertEqual(zi.extra, original.extra) self.assertEqual(zi.comment, original.comment) self.assertEqual(zi.internal_attr, original.internal_attr) self.assertEqual(zi.external_attr, original.external_attr)
def test_040_directory(self): zi = rozipinfo.ZipInfoRISCOS() zi.riscos_objtype = OBJTYPE_DIRECTORY self.assertEqual(zi.filename, 'NoName/') self.assertTrue(bool(zi.external_attr & 16), "Check for msdos directory bit") self.checkRISCOS(zi, filename=b'NoName', loadexec=build_loadexec(LOADADDR_BASEDATE, EXECADDR_BASEDATE, filetype=FILETYPE_DIRECTORY), filetype=FILETYPE_DIRECTORY, objtype=OBJTYPE_DIRECTORY, attr=ATTR_RW)
def test_004_zipinfo(self): # Check that it works when given a zipinfo original = zipfile.ZipInfo(filename='myfile', date_time=TESTDATE) zi = rozipinfo.ZipInfoRISCOS(zipinfo=original) self.assertIsNotNone(zi) self.assertEqual(zi.filename, original.filename) self.assertEqual(zi.date_time, original.date_time) self.assertEqual(zi.extra, original.extra) self.assertEqual(zi.comment, original.comment) self.assertEqual(zi.internal_attr, original.internal_attr) self.assertEqual(zi.external_attr, original.external_attr)