@@ -190,7 +190,7 @@ def it_can_iterate_over_its_relationships(self, request, _rels_prop_):
190190 part_0_ , part_1_ = [
191191 instance_mock (request , Part , name = "part_%d" % i ) for i in range (2 )
192192 ]
193- rels = tuple (
193+ all_rels = tuple (
194194 instance_mock (
195195 request ,
196196 _Relationship ,
@@ -208,18 +208,15 @@ def it_can_iterate_over_its_relationships(self, request, _rels_prop_):
208208 )
209209 )
210210 )
211- _rels_prop_ .return_value = rels [:3 ]
212- part_0_ .rels = rels [3 :4 ]
213- part_1_ .rels = rels [4 :]
211+ _rels_prop_ .return_value = { r . rId : r for r in all_rels [:3 ]}
212+ part_0_ .rels = { r . rId : r for r in all_rels [3 :4 ]}
213+ part_1_ .rels = { r . rId : r for r in all_rels [4 :]}
214214 package = OpcPackage (None )
215215
216- assert tuple (package .iter_rels ()) == (
217- rels [0 ],
218- rels [3 ],
219- rels [4 ],
220- rels [1 ],
221- rels [2 ],
222- )
216+ rels = set (package .iter_rels ())
217+
218+ # -- sequence is not guaranteed, but count (len) and uniqueness are --
219+ assert rels == set (all_rels )
223220
224221 def it_provides_access_to_the_main_document_part (self , request ):
225222 presentation_part_ = instance_mock (request , PresentationPart )
@@ -234,8 +231,7 @@ def it_provides_access_to_the_main_document_part(self, request):
234231 assert presentation_part is presentation_part_
235232
236233 @pytest .mark .parametrize (
237- "ns, expected_n" ,
238- (((), 1 ), ((1 ,), 2 ), ((1 , 2 ), 3 ), ((2 , 4 ), 3 ), ((1 , 4 ), 3 )),
234+ "ns, expected_n" , (((), 1 ), ((1 ,), 2 ), ((1 , 2 ), 3 ), ((2 , 4 ), 3 ), ((1 , 4 ), 3 ))
239235 )
240236 def it_can_find_the_next_available_partname (self , request , ns , expected_n ):
241237 tmpl = "/x%d.xml"
@@ -659,13 +655,15 @@ def but_it_raises_KeyError_when_no_relationship_has_rId(self, _rels_prop_):
659655 _Relationships (None )["rId6" ]
660656 assert str (e .value ) == "\" no relationship with key 'rId6'\" "
661657
662- def it_can_iterate_the_relationships_it_contains (self , request , _rels_prop_ ):
658+ def it_can_iterate_the_rIds_of_the_relationships_it_contains (
659+ self , request , _rels_prop_
660+ ):
663661 rels_ = set (instance_mock (request , _Relationship ) for n in range (5 ))
664662 _rels_prop_ .return_value = {"rId%d" % (i + 1 ): r for i , r in enumerate (rels_ )}
665663 relationships = _Relationships (None )
666664
667- for r in relationships :
668- rels_ .remove (r )
665+ for rId in relationships :
666+ rels_ .remove (relationships [ rId ] )
669667
670668 assert len (rels_ ) == 0
671669
@@ -795,10 +793,10 @@ def it_can_pop_a_relationship_to_remove_it_from_the_collection(
795793
796794 def it_can_serialize_itself_to_XML (self , request , _rels_prop_ ):
797795 _rels_prop_ .return_value = {
798- "rId1 " : instance_mock (
796+ "rId11 " : instance_mock (
799797 request ,
800798 _Relationship ,
801- rId = "rId1 " ,
799+ rId = "rId11 " ,
802800 reltype = RT .SLIDE ,
803801 target_ref = "../slides/slide1.xml" ,
804802 is_external = False ,
@@ -811,6 +809,14 @@ def it_can_serialize_itself_to_XML(self, request, _rels_prop_):
811809 target_ref = "http://url" ,
812810 is_external = True ,
813811 ),
812+ "foo7W" : instance_mock (
813+ request ,
814+ _Relationship ,
815+ rId = "foo7W" ,
816+ reltype = RT .IMAGE ,
817+ target_ref = "../media/image1.png" ,
818+ is_external = False ,
819+ ),
814820 }
815821 relationships = _Relationships (None )
816822
@@ -867,12 +873,7 @@ def and_it_can_add_an_external_relationship_to_help(
867873 ),
868874 )
869875 def it_can_get_a_matching_relationship_to_help (
870- self ,
871- request ,
872- _rels_by_reltype_prop_ ,
873- target_ref ,
874- is_external ,
875- expected_value ,
876+ self , request , _rels_by_reltype_prop_ , target_ref , is_external , expected_value
876877 ):
877878 part_1 , part_2 = (instance_mock (request , Part ) for _ in range (2 ))
878879 _rels_by_reltype_prop_ .return_value = {
@@ -996,12 +997,7 @@ def it_can_construct_from_xml(self, request, part_):
996997 relationship = _Relationship .from_xml ("/ppt" , rel_elm , parts )
997998
998999 _init_ .assert_called_once_with (
999- relationship ,
1000- "/ppt" ,
1001- "rId42" ,
1002- RT .SLIDE ,
1003- RTM .INTERNAL ,
1004- part_ ,
1000+ relationship , "/ppt" , "rId42" , RT .SLIDE , RTM .INTERNAL , part_
10051001 )
10061002 assert isinstance (relationship , _Relationship )
10071003
0 commit comments