<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> from behave import given , then <EOL> from pptx import Presentation <EOL> from pptx . parts . slidelayout import _LayoutPlaceholders , _LayoutShapeTree <EOL> from pptx . shapes . base import BaseShape <EOL> from pptx . shapes . picture import Picture <EOL> from pptx . shapes . placeholder import LayoutPlaceholder <EOL> from helpers import test_pptx <EOL> SHAPE_COUNT = <NUM_LIT:3> <EOL> @ given ( '<STR_LIT>' ) <EOL> def given_layout_placeholder_collection ( context ) : <EOL> prs = Presentation ( test_pptx ( '<STR_LIT>' ) ) <EOL> context . layout_placeholders = prs . slide_layouts [ <NUM_LIT:0> ] . placeholders <EOL> @ given ( '<STR_LIT>' ) <EOL> def given_layout_shape_collection ( context ) : <EOL> prs = Presentation ( test_pptx ( '<STR_LIT>' ) ) <EOL> context . layout_shapes = prs . slide_layouts [ <NUM_LIT:0> ] . shapes <EOL> @ given ( '<STR_LIT>' ) <EOL> def given_slide_layout_having_three_shapes ( context ) : <EOL> prs = Presentation ( test_pptx ( '<STR_LIT>' ) ) <EOL> context . slide_layout = prs . slide_layouts [ <NUM_LIT:0> ] <EOL> @ given ( '<STR_LIT>' ) <EOL> def given_layout_having_two_placeholders ( context ) : <EOL> prs = Presentation ( test_pptx ( '<STR_LIT>' ) ) <EOL> context . slide_layout = prs . slide_layouts [ <NUM_LIT:0> ] <EOL> @ then ( '<STR_LIT>' ) <EOL> def then_each_shape_is_of_appropriate_type ( context ) : <EOL> layout_shapes = context . layout_shapes <EOL> expected_types = [ LayoutPlaceholder , LayoutPlaceholder , Picture ] <EOL> for idx , layout_shape in enumerate ( layout_shapes ) : <EOL> assert type ( layout_shape ) == expected_types [ idx ] , ( <EOL> "<STR_LIT>" % type ( layout_shape ) . __name__ <EOL> ) <EOL> @ then ( '<STR_LIT>' ) <EOL> def then_can_access_layout_placeholder_by_idx_value ( context ) : <EOL> layout_placeholders = context . layout_placeholders <EOL> title_placeholder = layout_placeholders . get ( idx = <NUM_LIT:0> ) <EOL> body_placeholder = layout_placeholders . get ( idx = <NUM_LIT:10> ) <EOL> assert title_placeholder . _element is layout_placeholders [ <NUM_LIT:0> ] . _element <EOL> assert body_placeholder . _element is layout_placeholders [ <NUM_LIT:1> ] . _element <EOL> @ then ( '<STR_LIT>' ) <EOL> def then_can_access_layout_placeholder_by_index ( context ) : <EOL> layout_placeholders = context . layout_placeholders <EOL> for idx in range ( <NUM_LIT:2> ) : <EOL> layout_placeholder = layout_placeholders [ idx ] <EOL> assert isinstance ( layout_placeholder , LayoutPlaceholder ) <EOL> @ then ( '<STR_LIT>' ) <EOL> def then_can_access_layout_shape_by_index ( context ) : <EOL> layout_shapes = context . layout_shapes <EOL> for idx in range ( SHAPE_COUNT ) : <EOL> layout_shape = layout_shapes [ idx ] <EOL> assert isinstance ( layout_shape , BaseShape ) <EOL> @ then ( '<STR_LIT>' ) <EOL> def then_can_access_placeholder_collection_of_slide_layout ( context ) : <EOL> slide_layout = context . slide_layout <EOL> layout_placeholders = slide_layout . placeholders <EOL> msg = '<STR_LIT>' <EOL> assert isinstance ( layout_placeholders , _LayoutPlaceholders ) , msg <EOL> @ then ( '<STR_LIT>' ) <EOL> def then_can_access_shape_collection_of_slide_layout ( context ) : <EOL> slide_layout = context . slide_layout <EOL> layout_shapes = slide_layout . shapes <EOL> msg = '<STR_LIT>' <EOL> assert isinstance ( layout_shapes , _LayoutShapeTree ) , msg <EOL> @ then ( '<STR_LIT>' ) <EOL> def then_can_iterate_over_the_layout_placeholders ( context ) : <EOL> layout_placeholders = context . layout_placeholders <EOL> actual_count = <NUM_LIT:0> <EOL> for layout_placeholder in layout_placeholders : <EOL> actual_count += <NUM_LIT:1> <EOL> assert isinstance ( layout_placeholder , LayoutPlaceholder ) <EOL> assert actual_count == <NUM_LIT:2> <EOL> @ then ( '<STR_LIT>' ) <EOL> def then_can_iterate_over_the_layout_shapes ( context ) : <EOL> layout_shapes = context . layout_shapes <EOL> actual_count = <NUM_LIT:0> <EOL> for layout_shape in layout_shapes : <EOL> actual_count += <NUM_LIT:1> <EOL> assert isinstance ( layout_shape , BaseShape ) <EOL> assert actual_count == SHAPE_COUNT <EOL> @ then ( '<STR_LIT>' ) <EOL> def then_len_of_placeholder_collection_is_2 ( context ) : <EOL> slide_layout = context . slide_layout <EOL> layout_placeholders = slide_layout . placeholders <EOL> assert len ( layout_placeholders ) == <NUM_LIT:2> , ( <EOL> '<STR_LIT>' % <EOL> len ( layout_placeholders ) <EOL> ) <EOL> @ then ( '<STR_LIT>' ) <EOL> def then_len_of_layout_shape_collection_counts_all_its_shapes ( context ) : <EOL> slide_layout = context . slide_layout <EOL> layout_shapes = slide_layout . shapes <EOL> assert len ( layout_shapes ) == SHAPE_COUNT , ( <EOL> '<STR_LIT>' % <EOL> ( SHAPE_COUNT , len ( layout_shapes ) ) <EOL> ) </s>
