Пример #1
0
 def test_to_zip_manifest(self):
     fm = ByteStreamManager()
     fm.register('addfirst', 'SilentHill')
     fm.register('addsecond', 'SinCity')
     fm.register('mimetype', 'MaxPayne')
     zippo = ZipMock()
     fm._tozip(zippo)
     self.assertEqual(zippo.writtenfiles[0], 'mimetype',
                      "file 'mimetype' SHOULD be the first written file")
Пример #2
0
    def test_tobytes_result_content(self):
        def get_filelist(buffer):
            z = zipfile.ZipFile(io.BytesIO(buffer), 'r')
            files = z.namelist()
            z.close()
            return files

        data = self.get_empty_odt()
        fm = ByteStreamManager(data)
        mimetype = fm.get_bytes('mimetype')
        fm.register('mimetype', mimetype)
        result = fm.tobytes()
        self.assertEqual(mimetype, result[38:77])

        expected_files = get_filelist(data)
        result_files = get_filelist(result)
        self.assertSetEqual(set(expected_files), set(result_files))
Пример #3
0
 def test_tobytes_result_type(self):
     fm = ByteStreamManager()
     fm.register('addfirst', 'SilentHill')
     fm.register('addsecond', 'SinCity')
     fm.register('mimetype', 'MaxPayne')
     resultbuffer = fm.tobytes()
     self.assertTrue(is_zipfile(BytesIO(resultbuffer)))
Пример #4
0
 def test_to_zip_manifest(self):
     fm = ByteStreamManager()
     fm.register('addfirst', 'SilentHill')
     fm.register('addsecond', 'SinCity')
     fm.register('mimetype', 'MaxPayne')
     zippo = ZipMock()
     fm._tozip(zippo)
     self.assertEqual(zippo.writtenfiles[0],
                      'mimetype', "file 'mimetype' SHOULD be the first written file")
Пример #5
0
 def test_tobytes_result_type(self):
     fm = ByteStreamManager()
     fm.register('addfirst', 'SilentHill')
     fm.register('addsecond', 'SinCity')
     fm.register('mimetype', 'MaxPayne')
     resultbuffer = fm.tobytes()
     self.assertTrue(zipfile.is_zipfile(io.BytesIO(resultbuffer)))
Пример #6
0
    def test_tobytes_result_content(self):
        def get_filelist(buffer):
            z = zipfile.ZipFile(BytesIO(buffer), 'r')
            files = z.namelist()
            z.close()
            return files

        data = self.get_empty_odt()
        fm = ByteStreamManager(data)
        mimetype = fm.get_bytes('mimetype')
        fm.register('mimetype', mimetype)
        result = fm.tobytes()
        self.assertEqual(mimetype, result[38:77])

        expected_files = get_filelist(data)
        result_files = get_filelist(result)
        self.assertSetEqual(set(expected_files), set(result_files))
Пример #7
0
 def test_constructor(self):
     data = self.get_empty_odt()
     fm = ByteStreamManager(data)
     self.assertTrue(fm.has_zip())
Пример #8
0
 def test_constructor(self):
     data = self.get_empty_odt()
     fm = ByteStreamManager(data)
     self.assertTrue(fm.has_zip())