Skip to content

Commit

Permalink
acpt: add odd-even-page-headers scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
scanny committed Jan 6, 2019
1 parent 3923fe8 commit 1fd57de
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 9 deletions.
30 changes: 28 additions & 2 deletions features/doc-settings.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
Feature: Access to document settings
Feature: Document.settings
In order to operate on document-level settings
As a developer using python-docx
I access to settings stored in the settings part
I need access to settings to the Settings object for the document
And I need properties and methods on Settings


Scenario Outline: Access document settings
Expand All @@ -12,3 +13,28 @@ Feature: Access to document settings
| a-or-no |
| a |
| no |


@wip
Scenario Outline: Settings.odd_and_even_pages_header_footer getter
Given a Settings object <with-or-without> odd and even page headers as settings
Then settings.odd_and_even_pages_header_footer is <value>

Examples: Settings.odd_and_even_pages_header_footer states
| with-or-without | value |
| with | True |
| without | False |


@wip
Scenario Outline: Settings.odd_and_even_pages_header_footer setter
Given a Settings object <with-or-without> odd and even page headers as settings
When I assign <value> to settings.odd_and_even_pages_header_footer
Then settings.odd_and_even_pages_header_footer is <value>

Examples: Settings.odd_and_even_pages_header_footer assignment cases
| with-or-without | value |
| with | True |
| with | False |
| without | True |
| without | False |
34 changes: 27 additions & 7 deletions features/steps/settings.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# encoding: utf-8

"""
Step implementations for document settings-related features
"""
"""Step implementations for document settings-related features"""

from __future__ import (
absolute_import, division, print_function, unicode_literals
)
from __future__ import absolute_import, division, print_function, unicode_literals

from behave import given, then
from behave import given, then, when

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


@given("a Settings object {with_or_without} odd and even page headers as settings")
def given_a_Settings_object_with_or_without_odd_and_even_hdrs(context, with_or_without):
testfile_name = {
"with": "doc-odd-even-hdrs", "without": "sct-section-props"
}[with_or_without]
context.settings = Document(test_docx(testfile_name)).settings


# when =====================================================

@when("I assign {bool_val} to settings.odd_and_even_pages_header_footer")
def when_I_assign_value_to_settings_odd_and_even_pages_header_footer(context, bool_val):
context.settings.odd_and_even_pages_header_footer = eval(bool_val)


# then =====================================================

@then('document.settings is a Settings object')
def then_document_settings_is_a_Settings_object(context):
document = context.document
assert type(document.settings) is Settings


@then("settings.odd_and_even_pages_header_footer is {bool_val}")
def then_settings_odd_and_even_pages_header_footer_is(context, bool_val):
actual = context.settings.odd_and_even_pages_header_footer
expected = eval(bool_val)
assert actual == expected, (
"settings.odd_and_even_pages_header_footer is %s" % actual
)
Binary file added features/steps/test_files/doc-odd-even-hdrs.docx
Binary file not shown.

0 comments on commit 1fd57de

Please sign in to comment.