Example #1
0
def test_create_package_from_stream(zippack_sample):
	"""
	Not everybody wants to create a package from a file system object.
	Make sure the packages can be created from a stream.
	"""
	input_stream = io.BytesIO(zippack_sample)
	ZipPackage.from_stream(input_stream)
Example #2
0
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
Example #3
0
def test_store_empty_package():
	pack = ZipPackage()
	data = io.BytesIO()
	pack._store(data)
	data.seek(0)
	pack = ZipPackage.from_stream(data)