Skip to content

Commit faa7ab1

Browse files
author
Steve Canny
committed
acpt: add scenarios for LatentStyles properties
1 parent 3828b11 commit faa7ab1

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

features/steps/styles.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ def given_a_latent_style_collection(context):
6363
context.latent_styles = document.styles.latent_styles
6464

6565

66+
@given('a latent styles object with known defaults')
67+
def given_a_latent_styles_object_with_known_defaults(context):
68+
document = Document(test_docx('sty-known-styles'))
69+
context.latent_styles = document.styles.latent_styles
70+
71+
6672
@given('a style based on {base_style}')
6773
def given_a_style_based_on_setting(context, base_style):
6874
style_name = {
@@ -166,6 +172,13 @@ def when_I_assign_a_new_value_to_style_style_id(context):
166172
context.style.style_id = 'Foo42'
167173

168174

175+
@when('I assign {value} to latent_styles.{prop_name}')
176+
def when_I_assign_value_to_latent_styles_prop(context, value, prop_name):
177+
latent_styles = context.latent_styles
178+
new_value = bool_vals[value] if value in bool_vals else int(value)
179+
setattr(latent_styles, prop_name, new_value)
180+
181+
169182
@when('I assign {value_key} to style.base_style')
170183
def when_I_assign_value_to_style_base_style(context, value_key):
171184
value = {
@@ -264,6 +277,14 @@ def then_I_can_iterate_over_the_latent_styles(context):
264277
assert all(isinstance(ls, _LatentStyle) for ls in latent_styles)
265278

266279

280+
@then('latent_styles.{prop_name} is {value}')
281+
def then_latent_styles_prop_name_is_value(context, prop_name, value):
282+
latent_styles = context.latent_styles
283+
expected_value = bool_vals[value] if value in bool_vals else int(value)
284+
actual_value = getattr(latent_styles, prop_name)
285+
assert actual_value == expected_value
286+
287+
267288
@then('len(latent_styles) is 137')
268289
def then_len_latent_styles_is_137(context):
269290
assert len(context.latent_styles) == 137

features/sty-latent-props.feature

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Feature: Get and set latent style properties
2+
In order to adjust latent style properties to suit my needs
3+
As a developer using python-docx
4+
I need a set of read/write latent style properties
5+
6+
7+
@wip
8+
Scenario Outline: Get default latent style properties
9+
Given a latent styles object with known defaults
10+
Then latent_styles.<prop-name> is <value>
11+
12+
Examples: known latent_styles property values
13+
| prop-name | value |
14+
| default_priority | 99 |
15+
| load_count | 276 |
16+
| default_to_hidden | True |
17+
| default_to_locked | False |
18+
| default_to_quick_style | False |
19+
| default_to_unhide_when_used | True |
20+
21+
22+
@wip
23+
Scenario Outline: Set default latent style properties
24+
Given a latent styles object with known defaults
25+
When I assign <new-value> to latent_styles.<prop-name>
26+
Then latent_styles.<prop-name> is <value>
27+
28+
Examples: known latent_styles property values
29+
| prop-name | new-value | value |
30+
| default_priority | 42 | 42 |
31+
| load_count | 240 | 240 |
32+
| default_to_hidden | False | False |
33+
| default_to_locked | True | True |
34+
| default_to_quick_style | True | True |
35+
| default_to_unhide_when_used | False | False |

0 commit comments

Comments
 (0)