Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1fd57de

Browse files
committed
acpt: add odd-even-page-headers scenarios
1 parent 3923fe8 commit 1fd57de

File tree

3 files changed

+55
-9
lines changed

3 files changed

+55
-9
lines changed

features/doc-settings.feature

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
Feature: Access to document settings
1+
Feature: Document.settings
22
In order to operate on document-level settings
33
As a developer using python-docx
4-
I access to settings stored in the settings part
4+
I need access to settings to the Settings object for the document
5+
And I need properties and methods on Settings
56

67

78
Scenario Outline: Access document settings
@@ -12,3 +13,28 @@ Feature: Access to document settings
1213
| a-or-no |
1314
| a |
1415
| no |
16+
17+
18+
@wip
19+
Scenario Outline: Settings.odd_and_even_pages_header_footer getter
20+
Given a Settings object <with-or-without> odd and even page headers as settings
21+
Then settings.odd_and_even_pages_header_footer is <value>
22+
23+
Examples: Settings.odd_and_even_pages_header_footer states
24+
| with-or-without | value |
25+
| with | True |
26+
| without | False |
27+
28+
29+
@wip
30+
Scenario Outline: Settings.odd_and_even_pages_header_footer setter
31+
Given a Settings object <with-or-without> odd and even page headers as settings
32+
When I assign <value> to settings.odd_and_even_pages_header_footer
33+
Then settings.odd_and_even_pages_header_footer is <value>
34+
35+
Examples: Settings.odd_and_even_pages_header_footer assignment cases
36+
| with-or-without | value |
37+
| with | True |
38+
| with | False |
39+
| without | True |
40+
| without | False |

features/steps/settings.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
# encoding: utf-8
22

3-
"""
4-
Step implementations for document settings-related features
5-
"""
3+
"""Step implementations for document settings-related features"""
64

7-
from __future__ import (
8-
absolute_import, division, print_function, unicode_literals
9-
)
5+
from __future__ import absolute_import, division, print_function, unicode_literals
106

11-
from behave import given, then
7+
from behave import given, then, when
128

139
from docx import Document
1410
from docx.settings import Settings
@@ -28,9 +24,33 @@ def given_a_document_having_no_settings_part(context):
2824
context.document = Document(test_docx('set-no-settings-part'))
2925

3026

27+
@given("a Settings object {with_or_without} odd and even page headers as settings")
28+
def given_a_Settings_object_with_or_without_odd_and_even_hdrs(context, with_or_without):
29+
testfile_name = {
30+
"with": "doc-odd-even-hdrs", "without": "sct-section-props"
31+
}[with_or_without]
32+
context.settings = Document(test_docx(testfile_name)).settings
33+
34+
35+
# when =====================================================
36+
37+
@when("I assign {bool_val} to settings.odd_and_even_pages_header_footer")
38+
def when_I_assign_value_to_settings_odd_and_even_pages_header_footer(context, bool_val):
39+
context.settings.odd_and_even_pages_header_footer = eval(bool_val)
40+
41+
3142
# then =====================================================
3243

3344
@then('document.settings is a Settings object')
3445
def then_document_settings_is_a_Settings_object(context):
3546
document = context.document
3647
assert type(document.settings) is Settings
48+
49+
50+
@then("settings.odd_and_even_pages_header_footer is {bool_val}")
51+
def then_settings_odd_and_even_pages_header_footer_is(context, bool_val):
52+
actual = context.settings.odd_and_even_pages_header_footer
53+
expected = eval(bool_val)
54+
assert actual == expected, (
55+
"settings.odd_and_even_pages_header_footer is %s" % actual
56+
)
17.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)