13
13
14
14
from mock import call , Mock , patch
15
15
16
- from opc .pkgwriter import PackageWriter
16
+ from opc .pkgwriter import _ContentTypesItem , PackageWriter
17
+
18
+ from .unitutil import method_mock
17
19
18
20
19
21
class DescribePackageWriter (object ):
@@ -24,6 +26,10 @@ def PhysPkgWriter_(self, request):
24
26
request .addfinalizer (_patch .stop )
25
27
return _patch .start ()
26
28
29
+ @pytest .fixture
30
+ def xml_for (self , request ):
31
+ return method_mock (_ContentTypesItem , 'xml_for' , request )
32
+
27
33
@pytest .fixture
28
34
def _write_methods (self , request ):
29
35
"""Mock that patches all the _write_* methods of PackageWriter"""
@@ -60,3 +66,14 @@ def it_can_write_a_package(self, PhysPkgWriter_, _write_methods):
60
66
PhysPkgWriter_ .assert_called_once_with (pkg_file )
61
67
assert _write_methods .mock_calls == expected_calls
62
68
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