def test_getstream_correct_length(self): """ [Content_Types].xml retrieved as stream has correct element count """ fs = ZipFileSystem(zip_pkg_path) stream = fs.getstream("/[Content_Types].xml") content_types_elm = etree.parse(stream).getroot() assert_that(len(content_types_elm), is_(24))
def test_write_element_round_trips(self): """ZipFileSystem.write_element() round-trips intact""" # setup ----------------------- elm = etree.fromstring(self.xml_in) itemURI = "/ppt/test.xml" zipfs = ZipFileSystem(test_save_pptx_path, "w") # exercise -------------------- zipfs.write_element(elm, itemURI) # verify ---------------------- stream = zipfs.getstream(itemURI) xml_out = stream.read() stream.close() expected = self.xml_out actual = xml_out msg = "expected \n%s\n, got\n%s" % (expected, actual) self.assertEqual(expected, actual, msg)