@@ -192,6 +192,14 @@ def given_the_style_collection_of_a_document(context):
192
192
193
193
# when =====================================================
194
194
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
+
195
203
@when ('I assign a new name to the style' )
196
204
def when_I_assign_a_new_name_to_the_style (context ):
197
205
context .style .name = 'Foobar'
@@ -267,6 +275,14 @@ def when_I_call_add_style(context, name, type_str, builtin_str):
267
275
styles .add_style (name , type , builtin = builtin )
268
276
269
277
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
+
270
286
@when ('I delete a style' )
271
287
def when_I_delete_a_style (context ):
272
288
context .document .styles ['No List' ].delete ()
@@ -337,6 +353,13 @@ def then_latent_style_prop_name_is_value(context, prop_name, value):
337
353
assert actual_value == expected_value
338
354
339
355
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
+
340
363
@then ('latent_styles.{prop_name} is {value}' )
341
364
def then_latent_styles_prop_name_is_value (context , prop_name , value ):
342
365
latent_styles = context .latent_styles
@@ -468,6 +491,16 @@ def then_styles_name_is_a_style(context, name):
468
491
assert isinstance (style , BaseStyle )
469
492
470
493
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
+
471
504
@then ('the deleted style is not in the styles collection' )
472
505
def then_the_deleted_style_is_not_in_the_styles_collection (context ):
473
506
document = context .document
@@ -478,6 +511,14 @@ def then_the_deleted_style_is_not_in_the_styles_collection(context):
478
511
raise AssertionError ('Style not deleted' )
479
512
480
513
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
+
481
522
@then ('the document has one additional style' )
482
523
def then_the_document_has_one_additional_style (context ):
483
524
document = context .document
@@ -486,6 +527,13 @@ def then_the_document_has_one_additional_style(context):
486
527
assert style_count == expected_style_count
487
528
488
529
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
+
489
537
@then ('the document has one fewer styles' )
490
538
def then_the_document_has_one_fewer_styles (context ):
491
539
document = context .document
0 commit comments