1313
1414from mock import call , Mock , patch
1515
16- from opc .pkgwriter import PackageWriter
16+ from opc .pkgwriter import _ContentTypesItem , PackageWriter
17+
18+ from .unitutil import method_mock
1719
1820
1921class DescribePackageWriter (object ):
@@ -24,6 +26,10 @@ def PhysPkgWriter_(self, request):
2426 request .addfinalizer (_patch .stop )
2527 return _patch .start ()
2628
29+ @pytest .fixture
30+ def xml_for (self , request ):
31+ return method_mock (_ContentTypesItem , 'xml_for' , request )
32+
2733 @pytest .fixture
2834 def _write_methods (self , request ):
2935 """Mock that patches all the _write_* methods of PackageWriter"""
@@ -60,3 +66,14 @@ def it_can_write_a_package(self, PhysPkgWriter_, _write_methods):
6066 PhysPkgWriter_ .assert_called_once_with (pkg_file )
6167 assert _write_methods .mock_calls == expected_calls
6268 phys_writer .close .assert_called_once_with ()
69+
70+ def it_can_write_a_content_types_stream (self , xml_for ):
71+ # mockery ----------------------
72+ phys_writer = Mock (name = 'phys_writer' )
73+ parts = Mock (name = 'parts' )
74+ # exercise ---------------------
75+ PackageWriter ._write_content_types_stream (phys_writer , parts )
76+ # verify -----------------------
77+ xml_for .assert_called_once_with (parts )
78+ phys_writer .write .assert_called_once_with ('/[Content_Types].xml' ,
79+ xml_for .return_value )
0 commit comments