@@ -86,21 +86,25 @@ def test_storage_references_confluence(self):
8686
8787 # anchor in local-toc
8888 ltoc_entry = local_toc_entries .pop (0 )
89- ltoc_anchor = ltoc_entry .find (
89+ ltoc_anchors = ltoc_entry .find_all (
9090 'ac:structured-macro' , {'ac:name' : 'anchor' })
91- self .assertIsNotNone (ltoc_anchor )
92- anchor_param = ltoc_anchor .find ('ac:parameter' )
93- self .assertIsNotNone (anchor_param )
94- anchor_01_id = anchor_param .text
91+ self .assertGreaterEqual (len (ltoc_anchors ), 1 )
92+ anchor_01_ids = []
93+ for ltoc_anchor in ltoc_anchors :
94+ anchor_param = ltoc_anchor .find ('ac:parameter' )
95+ self .assertIsNotNone (anchor_param )
96+ anchor_01_ids .append (anchor_param .text )
9597
9698 # anchor in local-toc
9799 ltoc_entry = local_toc_entries .pop (0 )
98- ltoc_anchor = ltoc_entry .find (
100+ ltoc_anchors = ltoc_entry .find_all (
99101 'ac:structured-macro' , {'ac:name' : 'anchor' })
100- self .assertIsNotNone (ltoc_anchor )
101- anchor_param = ltoc_anchor .find ('ac:parameter' )
102- self .assertIsNotNone (anchor_param )
103- anchor_02_id = anchor_param .text
102+ self .assertGreaterEqual (len (ltoc_anchors ), 1 )
103+ anchor_02_ids = []
104+ for ltoc_anchor in ltoc_anchors :
105+ anchor_param = ltoc_anchor .find ('ac:parameter' )
106+ self .assertIsNotNone (anchor_param )
107+ anchor_02_ids .append (anchor_param .text )
104108
105109 # anchor after pre-content
106110 content_element = data .find ('p' , text = 'pre-content' )
@@ -138,15 +142,15 @@ def test_storage_references_confluence(self):
138142 # header link to a local-toc entry
139143 ac_link = ac_links .pop (0 )
140144 self .assertTrue (ac_link .has_attr ('ac:anchor' ))
141- self .assertEqual (ac_link ['ac:anchor' ], anchor_01_id )
145+ self .assertIn (ac_link ['ac:anchor' ], anchor_01_ids )
142146 ac_link_body = ac_link .find ('ac:link-body' )
143147 self .assertIsNotNone (ac_link_body )
144148 self .assertEqual (ac_link_body .text , 'An Extra Header' )
145149
146150 # header link to a local-toc entry
147151 ac_link = ac_links .pop (0 )
148152 self .assertTrue (ac_link .has_attr ('ac:anchor' ))
149- self .assertEqual (ac_link ['ac:anchor' ], anchor_02_id )
153+ self .assertIn (ac_link ['ac:anchor' ], anchor_02_ids )
150154 ac_link_body = ac_link .find ('ac:link-body' )
151155 self .assertIsNotNone (ac_link_body )
152156 self .assertEqual (ac_link_body .text , 'An Extra Header' )
@@ -295,21 +299,25 @@ def test_storage_references_confluence(self):
295299
296300 # anchor in local-toc
297301 ltoc_entry = local_toc_entries .pop (0 )
298- ltoc_anchor = ltoc_entry .find (
302+ ltoc_anchors = ltoc_entry .find_all (
299303 'ac:structured-macro' , {'ac:name' : 'anchor' })
300- self .assertIsNotNone (ltoc_anchor )
301- anchor_param = ltoc_anchor .find ('ac:parameter' )
302- self .assertIsNotNone (anchor_param )
303- anchor_01_id = anchor_param .text
304+ self .assertGreaterEqual (len (ltoc_anchors ), 1 )
305+ anchor_01_ids = []
306+ for ltoc_anchor in ltoc_anchors :
307+ anchor_param = ltoc_anchor .find ('ac:parameter' )
308+ self .assertIsNotNone (anchor_param )
309+ anchor_01_ids .append (anchor_param .text )
304310
305311 # anchor in local-toc
306312 ltoc_entry = local_toc_entries .pop (0 )
307- ltoc_anchor = ltoc_entry .find (
313+ ltoc_anchors = ltoc_entry .find_all (
308314 'ac:structured-macro' , {'ac:name' : 'anchor' })
309- self .assertIsNotNone (ltoc_anchor )
310- anchor_param = ltoc_anchor .find ('ac:parameter' )
311- self .assertIsNotNone (anchor_param )
312- anchor_02_id = anchor_param .text
315+ self .assertGreaterEqual (len (ltoc_anchors ), 1 )
316+ anchor_02_ids = []
317+ for ltoc_anchor in ltoc_anchors :
318+ anchor_param = ltoc_anchor .find ('ac:parameter' )
319+ self .assertIsNotNone (anchor_param )
320+ anchor_02_ids .append (anchor_param .text )
313321
314322 # anchor after pre-content
315323 content_element = data .find ('p' , text = 'pre-content' )
@@ -331,15 +339,15 @@ def test_storage_references_confluence(self):
331339 # header link to a local-toc entry
332340 ac_link = ac_links .pop (0 )
333341 self .assertTrue (ac_link .has_attr ('ac:anchor' ))
334- self .assertEqual (ac_link ['ac:anchor' ], anchor_01_id )
342+ self .assertIn (ac_link ['ac:anchor' ], anchor_01_ids )
335343 ac_link_body = ac_link .find ('ac:link-body' )
336344 self .assertIsNotNone (ac_link_body )
337345 self .assertEqual (ac_link_body .text , 'An Extra Header' )
338346
339347 # header link to a local-toc entry
340348 ac_link = ac_links .pop (0 )
341349 self .assertTrue (ac_link .has_attr ('ac:anchor' ))
342- self .assertEqual (ac_link ['ac:anchor' ], anchor_02_id )
350+ self .assertIn (ac_link ['ac:anchor' ], anchor_02_ids )
343351 ac_link_body = ac_link .find ('ac:link-body' )
344352 self .assertIsNotNone (ac_link_body )
345353 self .assertEqual (ac_link_body .text , 'An Extra Header' )
@@ -497,21 +505,25 @@ def test_storage_references_confluence(self):
497505
498506 # anchor in first header
499507 header_entry = header_entries .pop (0 )
500- header_anchor = header_entry .find (
508+ header_anchors = header_entry .find_all (
501509 'ac:structured-macro' , {'ac:name' : 'anchor' })
502- self .assertIsNotNone (header_anchor )
503- anchor_param = header_anchor .find ('ac:parameter' )
504- self .assertIsNotNone (anchor_param )
505- anchor_01_id = anchor_param .text
510+ self .assertGreaterEqual (len (ltoc_anchors ), 1 )
511+ anchor_01_ids = []
512+ for header_anchor in header_anchors :
513+ anchor_param = header_anchor .find ('ac:parameter' )
514+ self .assertIsNotNone (anchor_param )
515+ anchor_01_ids .append (anchor_param .text )
506516
507517 # anchor in second header
508518 header_entry = header_entries .pop (0 )
509- header_anchor = header_entry .find (
519+ header_anchors = header_entry .find_all (
510520 'ac:structured-macro' , {'ac:name' : 'anchor' })
511- self .assertIsNotNone (header_anchor )
512- anchor_param = header_anchor .find ('ac:parameter' )
513- self .assertIsNotNone (anchor_param )
514- anchor_02_id = anchor_param .text
521+ self .assertGreaterEqual (len (ltoc_anchors ), 1 )
522+ anchor_02_ids = []
523+ for header_anchor in header_anchors :
524+ anchor_param = header_anchor .find ('ac:parameter' )
525+ self .assertIsNotNone (anchor_param )
526+ anchor_02_ids .append (anchor_param .text )
515527
516528 # ##########################################################
517529 # find the expected ac:link macros
@@ -522,7 +534,7 @@ def test_storage_references_confluence(self):
522534 # heading jump to other heading
523535 ac_link = ac_links .pop (0 )
524536 self .assertTrue (ac_link .has_attr ('ac:anchor' ))
525- self .assertEqual (ac_link ['ac:anchor' ], anchor_01_id )
537+ self .assertIn (ac_link ['ac:anchor' ], anchor_01_ids )
526538 link_page = ac_link .find ('ri:page' )
527539 self .assertIsNone (link_page )
528540 ac_link_body = ac_link .find ('ac:link-body' )
@@ -532,7 +544,7 @@ def test_storage_references_confluence(self):
532544 # link to the sub-heading on this page
533545 ac_link = ac_links .pop (0 )
534546 self .assertTrue (ac_link .has_attr ('ac:anchor' ))
535- self .assertEqual (ac_link ['ac:anchor' ], anchor_01_id )
547+ self .assertIn (ac_link ['ac:anchor' ], anchor_01_ids )
536548 link_page = ac_link .find ('ri:page' )
537549 self .assertIsNone (link_page )
538550 ac_link_body = ac_link .find ('ac:link-body' )
@@ -543,7 +555,7 @@ def test_storage_references_confluence(self):
543555 # link to the second sub-heading on this page
544556 ac_link = ac_links .pop (0 )
545557 self .assertTrue (ac_link .has_attr ('ac:anchor' ))
546- self .assertEqual (ac_link ['ac:anchor' ], anchor_02_id )
558+ self .assertIn (ac_link ['ac:anchor' ], anchor_02_ids )
547559 link_page = ac_link .find ('ri:page' )
548560 self .assertIsNone (link_page )
549561 ac_link_body = ac_link .find ('ac:link-body' )
@@ -607,21 +619,25 @@ def test_storage_references_confluence(self):
607619
608620 # anchor in first header
609621 header_entry = header_entries .pop (0 )
610- header_anchor = header_entry .find (
622+ header_anchors = header_entry .find_all (
611623 'ac:structured-macro' , {'ac:name' : 'anchor' })
612- self .assertIsNotNone (header_anchor )
613- anchor_param = header_anchor .find ('ac:parameter' )
614- self .assertIsNotNone (anchor_param )
615- anchor_01_id = anchor_param .text
624+ self .assertGreaterEqual (len (ltoc_anchors ), 1 )
625+ anchor_01_ids = []
626+ for header_anchor in header_anchors :
627+ anchor_param = header_anchor .find ('ac:parameter' )
628+ self .assertIsNotNone (anchor_param )
629+ anchor_01_ids .append (anchor_param .text )
616630
617631 # anchor in second header
618632 header_entry = header_entries .pop (0 )
619- header_anchor = header_entry .find (
633+ header_anchors = header_entry .find_all (
620634 'ac:structured-macro' , {'ac:name' : 'anchor' })
621- self .assertIsNotNone (header_anchor )
622- anchor_param = header_anchor .find ('ac:parameter' )
623- self .assertIsNotNone (anchor_param )
624- anchor_02_id = anchor_param .text
635+ self .assertGreaterEqual (len (ltoc_anchors ), 1 )
636+ anchor_02_ids = []
637+ for header_anchor in header_anchors :
638+ anchor_param = header_anchor .find ('ac:parameter' )
639+ self .assertIsNotNone (anchor_param )
640+ anchor_02_ids .append (anchor_param .text )
625641
626642 # ##########################################################
627643 # find the expected ac:link macros
0 commit comments