def test_write_to_part(): pack = ZipPackage() part = p = SamplePart(pack, '/test/part.xml') pack[p.name] = p pack.content_types.add_override(p) pack.relate(p) part.data = '<test>hi there</test>'
def test_nested_content_loads(): """ Around 26:9448f50260f2, it was found that some content was not being loaded from sample documents. This test replicates that error. """ package = ZipPackage() main = SamplePart(package, '/test/main.xml') package[main.name] = main package.content_types.add_override(main) package.relate(main) main.data = '<test>this is the main module</test>' sub = SamplePart(package, '/test/sub.xml') package[sub.name] = sub package.content_types.add_override(sub) main.relate(sub) sub.data = '<test>this is the sub module</test>' serialized = io.BytesIO() package._store(serialized) serialized.seek(0) del package, main, sub package = ZipPackage.from_stream(serialized) assert '/test/main.xml' in package assert package['/test/main.xml'] sub = package['/test/sub.xml'] assert b'sub module' in sub.data
def test_save(writable_filename): pack = ZipPackage() part = p = SamplePart(pack, '/test/part.xml') pack[p.name] = p pack.content_types.add_override(p) pack.relate(p) part.data = '<test>hi there</test>' pack.save(writable_filename)
def test_add_part(): pack = ZipPackage() part = p = SamplePart(pack, '/test/part.xml') pack[p.name] = p pack.content_types.add_override(p) pack.relate(p)