@@ -192,6 +192,14 @@ def given_the_style_collection_of_a_document(context):
192192
193193# when =====================================================
194194
195+ @when ('I add a latent style named \' Foobar\' ' )
196+ def when_I_add_a_latent_style_named_Foobar (context ):
197+ latent_styles = context .document .styles .latent_styles
198+ context .latent_styles = latent_styles
199+ context .latent_style_count = len (latent_styles )
200+ latent_styles .add_latent_style ('Foobar' )
201+
202+
195203@when ('I assign a new name to the style' )
196204def when_I_assign_a_new_name_to_the_style (context ):
197205 context .style .name = 'Foobar'
@@ -267,6 +275,14 @@ def when_I_call_add_style(context, name, type_str, builtin_str):
267275 styles .add_style (name , type , builtin = builtin )
268276
269277
278+ @when ('I delete a latent style' )
279+ def when_I_delete_a_latent_style (context ):
280+ latent_styles = context .document .styles .latent_styles
281+ context .latent_styles = latent_styles
282+ context .latent_style_count = len (latent_styles )
283+ latent_styles ['Normal' ].delete ()
284+
285+
270286@when ('I delete a style' )
271287def when_I_delete_a_style (context ):
272288 context .document .styles ['No List' ].delete ()
@@ -337,6 +353,13 @@ def then_latent_style_prop_name_is_value(context, prop_name, value):
337353 assert actual_value == expected_value
338354
339355
356+ @then ('latent_styles[\' Foobar\' ] is a latent style' )
357+ def then_latentStyles_Foobar_is_a_latent_style (context ):
358+ latent_styles = context .latent_styles
359+ latent_style = latent_styles ['Foobar' ]
360+ assert isinstance (latent_style , _LatentStyle )
361+
362+
340363@then ('latent_styles.{prop_name} is {value}' )
341364def then_latent_styles_prop_name_is_value (context , prop_name , value ):
342365 latent_styles = context .latent_styles
@@ -468,6 +491,16 @@ def then_styles_name_is_a_style(context, name):
468491 assert isinstance (style , BaseStyle )
469492
470493
494+ @then ('the deleted latent style is not in the latent styles collection' )
495+ def then_the_deleted_latent_style_is_not_in_the_collection (context ):
496+ latent_styles = context .latent_styles
497+ try :
498+ latent_styles ['Normal' ]
499+ except KeyError :
500+ return
501+ raise AssertionError ('Latent style not deleted' )
502+
503+
471504@then ('the deleted style is not in the styles collection' )
472505def then_the_deleted_style_is_not_in_the_styles_collection (context ):
473506 document = context .document
@@ -478,6 +511,14 @@ def then_the_deleted_style_is_not_in_the_styles_collection(context):
478511 raise AssertionError ('Style not deleted' )
479512
480513
514+ @then ('the document has one additional latent style' )
515+ def then_the_document_has_one_additional_latent_style (context ):
516+ latent_styles = context .document .styles .latent_styles
517+ latent_style_count = len (latent_styles )
518+ expected_count = context .latent_style_count + 1
519+ assert latent_style_count == expected_count
520+
521+
481522@then ('the document has one additional style' )
482523def then_the_document_has_one_additional_style (context ):
483524 document = context .document
@@ -486,6 +527,13 @@ def then_the_document_has_one_additional_style(context):
486527 assert style_count == expected_style_count
487528
488529
530+ @then ('the document has one fewer latent styles' )
531+ def then_the_document_has_one_fewer_latent_styles (context ):
532+ latent_style_count = len (context .latent_styles )
533+ expected_count = context .latent_style_count - 1
534+ assert latent_style_count == expected_count
535+
536+
489537@then ('the document has one fewer styles' )
490538def then_the_document_has_one_fewer_styles (context ):
491539 document = context .document
0 commit comments