1717
1818# given ===================================================
1919
20- @given ('a document containing two inline shapes' )
20+ @given ('a document containing five inline shapes' )
2121def given_a_document_containing_two_inline_shapes (context ):
2222 docx_path = test_docx ('shp-inline-shape-access' )
2323 context .document = Document (docx_path )
2424
2525
26- @given ('an inline shape collection containing two shapes' )
26+ @given ('an inline shape collection containing five shapes' )
2727def given_inline_shape_collection_containing_two_shapes (context ):
2828 docx_path = test_docx ('shp-inline-shape-access' )
2929 document = Document (docx_path )
@@ -33,8 +33,11 @@ def given_inline_shape_collection_containing_two_shapes(context):
3333@given ('an inline shape known to be {shp_of_type}' )
3434def given_inline_shape_known_to_be_shape_of_type (context , shp_of_type ):
3535 inline_shape_idx = {
36- 'an embedded picture' : 0 ,
37- 'a linked picture' : 1 ,
36+ 'an embedded picture' : 0 ,
37+ 'a linked picture' : 1 ,
38+ 'a link+embed picture' : 2 ,
39+ 'a smart art diagram' : 3 ,
40+ 'a chart' : 4 ,
3841 }[shp_of_type ]
3942 docx_path = test_docx ('shp-inline-shape-access' )
4043 document = Document (docx_path )
@@ -43,8 +46,8 @@ def given_inline_shape_known_to_be_shape_of_type(context, shp_of_type):
4346
4447# then =====================================================
4548
46- @then ('I can access an inline shape by index' )
47- def then_can_access_inline_shape_by_index (context ):
49+ @then ('I can access each inline shape by index' )
50+ def then_can_access_each_inline_shape_by_index (context ):
4851 inline_shapes = context .inline_shapes
4952 for idx in range (2 ):
5053 inline_shape = inline_shapes [idx ]
@@ -61,24 +64,30 @@ def then_can_access_inline_shape_collection_of_document(context):
6164@then ('I can iterate over the inline shape collection' )
6265def then_can_iterate_over_inline_shape_collection (context ):
6366 inline_shapes = context .inline_shapes
64- actual_count = 0
67+ shape_count = 0
6568 for inline_shape in inline_shapes :
66- actual_count += 1
69+ shape_count += 1
6770 assert isinstance (inline_shape , InlineShape )
68- assert actual_count == 2
71+ expected_count = 5
72+ assert shape_count == expected_count , (
73+ 'expected %d, got %d' % (expected_count , shape_count )
74+ )
6975
7076
7177@then ('its inline shape type is {shape_type}' )
7278def then_inline_shape_type_is_shape_type (context , shape_type ):
7379 expected_value = {
74- 'WD_INLINE_SHAPE.PICTURE ' : WD_INLINE_SHAPE .PICTURE ,
80+ 'WD_INLINE_SHAPE.CHART ' : WD_INLINE_SHAPE .CHART ,
7581 'WD_INLINE_SHAPE.LINKED_PICTURE' : WD_INLINE_SHAPE .LINKED_PICTURE ,
82+ 'WD_INLINE_SHAPE.PICTURE' : WD_INLINE_SHAPE .PICTURE ,
83+ 'WD_INLINE_SHAPE.SMART_ART' : WD_INLINE_SHAPE .SMART_ART ,
7684 }[shape_type ]
7785 inline_shape = context .inline_shape
7886 assert inline_shape .type == expected_value
7987
8088
81- @then ('the length of the inline shape collection is 2 ' )
82- def then_len_of_inline_shape_collection_is_2 (context ):
89+ @then ('the length of the inline shape collection is 5 ' )
90+ def then_len_of_inline_shape_collection_is_5 (context ):
8391 inline_shapes = context .document .inline_shapes
84- assert len (inline_shapes ) == 2
92+ shape_count = len (inline_shapes )
93+ assert shape_count == 5 , 'got %s' % shape_count
0 commit comments