Commits

Jason R. Coombs  committed 1a773c2

Removed another attribute from basepack (start_part), as it doesn't appear to be relevant until we have an Office Package.
Created test suite for officepack.
Changed OfficePackage.start_part to be a read-only property, as I believe that's how it is used.

  • Participants
  • Parent commits 71830e5

Comments (0)

Files changed (4)

File openpack/basepack.py

 		self.content_types = ContentTypes()
 		self.content_types.add(ContentType.Default(rels.content_type, 'rels'))
 		self.core_properties = None
-		self.start_part = None
 	
 	def __setitem__(self, name, part):
 		self._validate_part(name, part)

File openpack/officepack.py

 from zippack import ZipPackage
 
 class OfficePackage(ZipPackage):
-	"""Handles MSOffice files and correctly sets the start part."""
+	"""
+	A Microsoft Office OOXML package.
+	"""
 
 	main_rel = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"
 
-	def open(self):
-		ZipPackage.open(self)
-		# set the first occurence of the officeDocument relationship as the
-		# "start part" for the package
-		self.start_part = self.related(self.main_rel)[0]
+	@property
+	def start_part(self):
+		return self.related(self.main_rel)[0]
 
 

File test/empty.docx

Binary file added.

File test/test_officepack.py

+import pkg_resources
+
+import py.test
+
+from openpack.officepack import OfficePackage
+
+def pytest_funcarg__officepack_sample(request):
+	return pkg_resources.resource_stream(__name__, 'empty.docx')
+
+def test_open(officepack_sample):
+	doc = OfficePackage.from_stream(officepack_sample)
+
+def test_start_part(officepack_sample):
+	doc = OfficePackage.from_stream(officepack_sample)
+	assert doc.start_part