-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathheader.py
More file actions
49 lines (34 loc) · 1.35 KB
/
header.py
File metadata and controls
49 lines (34 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# encoding: utf-8
"""
Step implementations for header-related features
"""
from __future__ import (
absolute_import, division, print_function, unicode_literals
)
from behave import given, then
from docx import Document
from helpers import test_docx
# given ===================================================
@given('a header {having_or_no} definition')
def given_a_header_having_or_no_definition(context, having_or_no):
filename = {
'having a': 'hdr-header-props',
'having no': 'doc-default',
}[having_or_no]
document = Document(test_docx(filename))
context.header = document.sections[0].header
# then =====================================================
@then('header.body contains the text of the header')
def then_header_body_contains_the_text_of_the_header(context):
header = context.header
text = header.body.paragraphs[0].text
assert text == 'S1HP1'
@then('header.body is a BlockItemContainer object')
def then_header_body_is_a_BlockItemContainer_object(context):
header = context.header
assert type(header.body).__name__ == 'BlockItemContainer'
@then('header.is_linked_to_previous is {value}')
def then_header_is_linked_to_previous_is_value(context, value):
expected_value = {'True': True, 'False': False}[value]
header = context.header
assert header.is_linked_to_previous is expected_value