1515
1616from mock import Mock
1717
18- from .unitutil import function_mock , initializer_mock
18+ from .unitutil import class_mock , function_mock , initializer_mock
1919
2020
2121class Describe_Document (object ):
2222
23+ @pytest .fixture
24+ def _Body_ (self , request ):
25+ return class_mock ('docx.parts._Body' , request )
26+
2327 @pytest .fixture
2428 def init (self , request ):
2529 return initializer_mock (_Document , request )
@@ -28,8 +32,8 @@ def init(self, request):
2832 def oxml_fromstring_ (self , request ):
2933 return function_mock ('docx.parts.oxml_fromstring' , request )
3034
31- def it_can_be_constructed_by_opc_part_factory (self , oxml_fromstring_ ,
32- init ):
35+ def it_can_be_constructed_by_opc_part_factory (
36+ self , oxml_fromstring_ , init ):
3337 # mockery ----------------------
3438 partname , content_type , blob , document_elm = (
3539 Mock (name = 'partname' ), Mock (name = 'content_type' ),
@@ -42,3 +46,13 @@ def it_can_be_constructed_by_opc_part_factory(self, oxml_fromstring_,
4246 oxml_fromstring_ .assert_called_once_with (blob )
4347 init .assert_called_once_with (partname , content_type , document_elm )
4448 assert isinstance (doc , _Document )
49+
50+ def it_has_a_body (self , init , _Body_ ):
51+ # mockery ----------------------
52+ doc = _Document (None , None , None )
53+ doc ._element = Mock (name = '_element' )
54+ # exercise ---------------------
55+ body = doc .body
56+ # verify -----------------------
57+ _Body_ .assert_called_once_with (doc ._element .body )
58+ assert body is _Body_ .return_value
0 commit comments