Skip to content

Commit 21cd98c

Browse files
author
Steve Canny
committed
acpt: add scenarios for _Style.name
1 parent ba9c2a2 commit 21cd98c

2 files changed

Lines changed: 29 additions & 8 deletions

File tree

features/steps/styles.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,19 @@ def given_a_document_having_no_styles_part(context):
2828
context.document = Document(docx_path)
2929

3030

31-
@given('a style having a known style id')
32-
def given_a_style_having_a_known_style_id(context):
31+
@given('a style having a known {attr_name}')
32+
def given_a_style_having_a_known_attr_name(context, attr_name):
3333
docx_path = test_docx('sty-having-styles-part')
3434
document = Document(docx_path)
3535
context.style = document.styles['Normal']
3636

3737

38-
@given('a style having a known type')
39-
def given_a_style_having_a_known_type(context):
40-
docx_path = test_docx('sty-having-styles-part')
41-
document = Document(docx_path)
42-
context.style = document.styles['Normal']
38+
# when =====================================================
4339

40+
@when('I assign a new name to the style')
41+
def when_I_assign_a_new_name_to_the_style(context):
42+
context.style.name = 'Foobar'
4443

45-
# when =====================================================
4644

4745
@when('I assign a new value to style.style_id')
4846
def when_I_assign_a_new_value_to_style_style_id(context):
@@ -84,6 +82,16 @@ def then_len_styles_is_style_count(context, style_count_str):
8482
assert len(context.document.styles) == int(style_count_str)
8583

8684

85+
@then('style.name is the {which} name')
86+
def then_style_name_is_the_which_name(context, which):
87+
expected_name = {
88+
'known': 'Normal',
89+
'new': 'Foobar',
90+
}[which]
91+
style = context.style
92+
assert style.name == expected_name
93+
94+
8795
@then('style.style_id is the {which} style id')
8896
def then_style_style_id_is_the_which_style_id(context, which):
8997
expected_style_id = {

features/sty-style-props.feature

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ Feature: Get and set style properties
44
I need a set of read/write style properties
55

66

7+
@wip
8+
Scenario: Get name
9+
Given a style having a known name
10+
Then style.name is the known name
11+
12+
13+
@wip
14+
Scenario: Set name
15+
Given a style having a known name
16+
When I assign a new name to the style
17+
Then style.name is the new name
18+
19+
720
Scenario: Get style id
821
Given a style having a known style id
922
Then style.style_id is the known style id

0 commit comments

Comments
 (0)