@@ -63,6 +63,36 @@ def given_a_latent_style_collection(context):
63
63
context .latent_styles = document .styles .latent_styles
64
64
65
65
66
+ @given ('a latent style having a known name' )
67
+ def given_a_latent_style_having_a_known_name (context ):
68
+ document = Document (test_docx ('sty-known-styles' ))
69
+ latent_styles = list (document .styles .latent_styles )
70
+ context .latent_style = latent_styles [0 ] # should be 'Normal'
71
+
72
+
73
+ @given ('a latent style having priority of {setting}' )
74
+ def given_a_latent_style_having_priority_of_setting (context , setting ):
75
+ latent_style_name = {
76
+ '42' : 'Normal' ,
77
+ 'no setting' : 'Subtitle' ,
78
+ }[setting ]
79
+ document = Document (test_docx ('sty-known-styles' ))
80
+ latent_styles = document .styles .latent_styles
81
+ context .latent_style = latent_styles [latent_style_name ]
82
+
83
+
84
+ @given ('a latent style having {prop_name} set {setting}' )
85
+ def given_a_latent_style_having_prop_setting (context , prop_name , setting ):
86
+ latent_style_name = {
87
+ 'on' : 'Normal' ,
88
+ 'off' : 'Title' ,
89
+ 'no setting' : 'Subtitle' ,
90
+ }[setting ]
91
+ document = Document (test_docx ('sty-known-styles' ))
92
+ latent_styles = document .styles .latent_styles
93
+ context .latent_style = latent_styles [latent_style_name ]
94
+
95
+
66
96
@given ('a latent styles object with known defaults' )
67
97
def given_a_latent_styles_object_with_known_defaults (context ):
68
98
document = Document (test_docx ('sty-known-styles' ))
@@ -172,6 +202,15 @@ def when_I_assign_a_new_value_to_style_style_id(context):
172
202
context .style .style_id = 'Foo42'
173
203
174
204
205
+ @when ('I assign {value} to latent_style.{prop_name}' )
206
+ def when_I_assign_value_to_latent_style_prop (context , value , prop_name ):
207
+ latent_style = context .latent_style
208
+ new_value = (
209
+ tri_state_vals [value ] if value in tri_state_vals else int (value )
210
+ )
211
+ setattr (latent_style , prop_name , new_value )
212
+
213
+
175
214
@when ('I assign {value} to latent_styles.{prop_name}' )
176
215
def when_I_assign_value_to_latent_styles_prop (context , value , prop_name ):
177
216
latent_styles = context .latent_styles
@@ -277,6 +316,27 @@ def then_I_can_iterate_over_the_latent_styles(context):
277
316
assert all (isinstance (ls , _LatentStyle ) for ls in latent_styles )
278
317
279
318
319
+ @then ('latent_style.name is the known name' )
320
+ def then_latent_style_name_is_the_known_name (context ):
321
+ latent_style = context .latent_style
322
+ assert latent_style .name == 'Normal'
323
+
324
+
325
+ @then ('latent_style.priority is {value}' )
326
+ def then_latent_style_priority_is_value (context , value ):
327
+ latent_style = context .latent_style
328
+ expected_value = None if value == 'None' else int (value )
329
+ assert latent_style .priority == expected_value
330
+
331
+
332
+ @then ('latent_style.{prop_name} is {value}' )
333
+ def then_latent_style_prop_name_is_value (context , prop_name , value ):
334
+ latent_style = context .latent_style
335
+ actual_value = getattr (latent_style , prop_name )
336
+ expected_value = tri_state_vals [value ]
337
+ assert actual_value == expected_value
338
+
339
+
280
340
@then ('latent_styles.{prop_name} is {value}' )
281
341
def then_latent_styles_prop_name_is_value (context , prop_name , value ):
282
342
latent_styles = context .latent_styles
0 commit comments