예제 #1
0
 def test_drawing_template(self):
     path = join("..", "odfdo", "templates", "drawing.otg")
     container = Container.new(path)
     mimetype = container.get_part("mimetype")
     umimetype = container.mimetype
     self.assertEqual(mimetype, to_bytes(ODF_EXTENSIONS["odg"]))
     self.assertEqual(umimetype, ODF_EXTENSIONS["odg"])
예제 #2
0
 def test_text_template(self):
     path = '../odfdo/templates/text.ott'
     container = Container.new(path)
     mimetype = container.get_part('mimetype')
     umimetype = container.mimetype
     self.assertEqual(mimetype, to_bytes(ODF_EXTENSIONS['odt']))
     self.assertEqual(umimetype, ODF_EXTENSIONS['odt'])
예제 #3
0
 def test_presentation_template(self):
     path = join('..', 'odfdo', 'templates', 'presentation.otp')
     container = Container.new(path)
     mimetype = container.get_part('mimetype')
     umimetype = container.mimetype
     self.assertEqual(mimetype, to_bytes(ODF_EXTENSIONS['odp']))
     self.assertEqual(umimetype, ODF_EXTENSIONS['odp'])
예제 #4
0
 def test_drawing_template(self):
     path = join('..', 'odfdo', 'templates', 'drawing.otg')
     container = Container.new(path)
     mimetype = container.get_part('mimetype')
     umimetype = container.mimetype
     self.assertEqual(mimetype, to_bytes(ODF_EXTENSIONS['odg']))
     self.assertEqual(umimetype, ODF_EXTENSIONS['odg'])
예제 #5
0
 def test_get_part_mimetype(self):
     container = Container()
     container.open(join('samples', 'example.odt'))
     mimetype = container.get_part('mimetype')
     umimetype = container.mimetype
     self.assertEqual(mimetype, to_bytes(ODF_EXTENSIONS['odt']))
     self.assertEqual(umimetype, ODF_EXTENSIONS['odt'])
예제 #6
0
 def test_spreadsheet_template(self):
     path = join('..', 'odfdo', 'templates', 'spreadsheet.ots')
     container = Container.new(path)
     mimetype = container.get_part('mimetype')
     umimetype = container.mimetype
     self.assertEqual(mimetype, to_bytes(ODF_EXTENSIONS['ods']))
     self.assertEqual(umimetype, ODF_EXTENSIONS['ods'])
예제 #7
0
 def test_get_part_mimetype(self):
     container = Container()
     container.open(join("samples", "example.odt"))
     mimetype = container.get_part("mimetype")
     umimetype = container.mimetype
     self.assertEqual(mimetype, to_bytes(ODF_EXTENSIONS["odt"]))
     self.assertEqual(umimetype, ODF_EXTENSIONS["odt"])
예제 #8
0
 def test_set_part(self):
     container = Container()
     container.open(join("samples", "example.odt"))
     path = join("Pictures", "a.jpg")
     data = to_bytes("JFIFIThinéééékImAnImage")
     container.set_part(path, data)
     self.assertEqual(container.get_part(path), data)
예제 #9
0
 def test_set_part(self):
     container = Container()
     container.open(join('samples', 'example.odt'))
     path = join('Pictures', 'a.jpg')
     data = to_bytes('JFIFIThinéééékImAnImage')
     container.set_part(path, data)
     self.assertEqual(container.get_part(path), data)
예제 #10
0
 def test_presentation_template(self):
     path = join("..", "odfdo", "templates", "presentation.otp")
     container = Container.new(path)
     mimetype = container.get_part("mimetype")
     umimetype = container.mimetype
     self.assertEqual(mimetype, to_bytes(ODF_EXTENSIONS["odp"]))
     self.assertEqual(umimetype, ODF_EXTENSIONS["odp"])
예제 #11
0
 def test_spreadsheet_template(self):
     path = join("..", "odfdo", "templates", "spreadsheet.ots")
     container = Container.new(path)
     mimetype = container.get_part("mimetype")
     umimetype = container.mimetype
     self.assertEqual(mimetype, to_bytes(ODF_EXTENSIONS["ods"]))
     self.assertEqual(umimetype, ODF_EXTENSIONS["ods"])
예제 #12
0
 def test_filesystem(self):
     path = join('samples', 'example.odt')
     container = Container()
     container.open(path)
     mimetype = container.get_part('mimetype')
     umimetype = container.mimetype
     self.assertEqual(mimetype, to_bytes(ODF_EXTENSIONS['odt']))
     self.assertEqual(umimetype, ODF_EXTENSIONS['odt'])
예제 #13
0
 def test_filesystem(self):
     path = join("samples", "example.odt")
     container = Container()
     container.open(path)
     mimetype = container.get_part("mimetype")
     umimetype = container.mimetype
     self.assertEqual(mimetype, to_bytes(ODF_EXTENSIONS["odt"]))
     self.assertEqual(umimetype, ODF_EXTENSIONS["odt"])
예제 #14
0
 def test_load_folder(self):
     container = Container()
     container.open(join("samples", "example.odt"))
     container.save(join("trash", "example_f.odt"), packaging="folder")
     new_container = Container()
     new_container.open(join("trash", "example_f.odt.folder"))
     content = new_container.get_part(ODF_CONTENT)
     self.assertIn(b"<office:document-content", content)
     mimetype = new_container.get_part("mimetype")
     self.assertEqual(mimetype, to_bytes(ODF_EXTENSIONS["odt"]))
     path = join("Pictures", "a.jpg")
     data = to_bytes("JFIFIThiééénkImA §ççànImage")
     new_container.set_part(path, data)
     self.assertEqual(new_container.get_part(path), to_bytes(data))
     # Not a realistic test
     path = "content"
     new_container.del_part(path)
     self.assertRaises(ValueError, new_container.get_part, path)
예제 #15
0
 def test_load_folder(self):
     container = Container()
     container.open(join('samples', 'example.odt'))
     container.save(join('trash', 'example_f.odt'), packaging='folder')
     new_container = Container()
     new_container.open(join('trash', 'example_f.odt.folder'))
     content = new_container.get_part(ODF_CONTENT)
     self.assertIn(b'<office:document-content', content)
     mimetype = new_container.get_part('mimetype')
     self.assertEqual(mimetype, to_bytes(ODF_EXTENSIONS['odt']))
     path = join('Pictures', 'a.jpg')
     data = to_bytes('JFIFIThiééénkImA §ççànImage')
     new_container.set_part(path, data)
     self.assertEqual(new_container.get_part(path), to_bytes(data))
     # Not a realistic test
     path = 'content'
     new_container.del_part(path)
     self.assertRaises(ValueError, new_container.get_part, path)
예제 #16
0
 def test_save_zip(self):
     """TODO: 2 cases
     1. from "zip" to "zip"
     2. from "flat" to "zip"
     """
     container = Container()
     container.open(join("samples", "example.odt"))
     container.save(join("trash", "example.odt"))
     new_container = Container()
     new_container.open(join("trash", "example.odt"))
     mimetype = new_container.get_part("mimetype")
     self.assertEqual(mimetype, to_bytes(ODF_EXTENSIONS["odt"]))
예제 #17
0
 def test_save_zip(self):
     """TODO: 2 cases
        1. from "zip" to "zip"
        2. from "flat" to "zip"
     """
     container = Container()
     container.open(join('samples', 'example.odt'))
     container.save(join('trash', 'example.odt'))
     new_container = Container()
     new_container.open(join('trash', 'example.odt'))
     mimetype = new_container.get_part('mimetype')
     self.assertEqual(mimetype, to_bytes(ODF_EXTENSIONS['odt']))
예제 #18
0
 def test_save_folder_to_zip(self):
     container = Container()
     container.open(join("samples", "example.odt"))
     container.save(join("trash", "example.odt"), packaging="folder")
     path = join("trash", "example.odt" + ".folder", "mimetype")
     self.assertEqual(isfile(path), True)
     new_container = Container()
     new_container.open(join("trash", "example.odt.folder"))
     new_container.save(join("trash", "example_bis.odt"), packaging="zip")
     new_container_zip = Container()
     new_container_zip.open(join("trash", "example_bis.odt"))
     mimetype = new_container_zip.get_part("mimetype")
     self.assertEqual(mimetype, to_bytes(ODF_EXTENSIONS["odt"]))
예제 #19
0
 def test_save_folder_to_zip(self):
     container = Container()
     container.open(join('samples', 'example.odt'))
     container.save(join('trash', 'example.odt'), packaging='folder')
     path = join('trash', 'example.odt' + '.folder', 'mimetype')
     self.assertEqual(isfile(path), True)
     new_container = Container()
     new_container.open(join('trash', 'example.odt.folder'))
     new_container.save(join('trash', 'example_bis.odt'), packaging='zip')
     new_container_zip = Container()
     new_container_zip.open(join('trash', 'example_bis.odt'))
     mimetype = new_container_zip.get_part('mimetype')
     self.assertEqual(mimetype, to_bytes(ODF_EXTENSIONS['odt']))
예제 #20
0
 def test_spreadsheet_type(self):
     container = Container.new("spreadsheet")
     mimetype = container.get_part("mimetype")
     umimetype = container.mimetype
     self.assertEqual(mimetype, to_bytes(ODF_EXTENSIONS["ods"]))
     self.assertEqual(umimetype, ODF_EXTENSIONS["ods"])
예제 #21
0
 def test_drawing_type(self):
     container = Container.new("drawing")
     mimetype = container.get_part("mimetype")
     umimetype = container.mimetype
     self.assertEqual(mimetype, to_bytes(ODF_EXTENSIONS["odg"]))
     self.assertEqual(umimetype, ODF_EXTENSIONS["odg"])
예제 #22
0
 def test_spreadsheet_type(self):
     container = Container.new('spreadsheet')
     mimetype = container.get_part('mimetype')
     umimetype = container.mimetype
     self.assertEqual(mimetype, to_bytes(ODF_EXTENSIONS['ods']))
     self.assertEqual(umimetype, ODF_EXTENSIONS['ods'])
예제 #23
0
 def test_drawing_type(self):
     container = Container.new('drawing')
     mimetype = container.get_part('mimetype')
     umimetype = container.mimetype
     self.assertEqual(mimetype, to_bytes(ODF_EXTENSIONS['odg']))
     self.assertEqual(umimetype, ODF_EXTENSIONS['odg'])
예제 #24
0
 def test_presentation_type(self):
     container = Container.new("presentation")
     mimetype = container.get_part("mimetype")
     umimetype = container.mimetype
     self.assertEqual(mimetype, to_bytes(ODF_EXTENSIONS["odp"]))
     self.assertEqual(umimetype, ODF_EXTENSIONS["odp"])
예제 #25
0
 def test_presentation_type(self):
     container = Container.new('presentation')
     mimetype = container.get_part('mimetype')
     umimetype = container.mimetype
     self.assertEqual(mimetype, to_bytes(ODF_EXTENSIONS['odp']))
     self.assertEqual(umimetype, ODF_EXTENSIONS['odp'])