Skip to content

Commit 794af7d

Browse files
Benjamin Toornstrascanny
authored andcommitted
acpt: Add scenario for named bookmark access
1 parent ad44458 commit 794af7d

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

features/bmk-bookmarks.feature

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,16 @@ Feature: Access a bookmark
99
Then len(bookmarks) == 5
1010
And bookmarks[1] is a _Bookmark object
1111
And iterating bookmarks produces 5 _Bookmark objects
12+
13+
@wip
14+
Scenario Outline: Bookmarks.get(bookmark_name)
15+
Given a Bookmarks object of length 5 as bookmarks
16+
Then bookmarks.get(<name>) returns bookmark named "<name>" with id <id>
17+
18+
Examples: Named Bookmarks
19+
| name | id |
20+
| bookmark_body | 2 |
21+
| bookmark_endnote | 1 |
22+
| bookmark_footer | 5 |
23+
| bookmark_footnote | 0 |
24+
| bookmark_header | 4 |

features/steps/bookmarks.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
"""Step implementations for bookmark-related features."""
44

5-
from __future__ import (
6-
absolute_import, division, print_function, unicode_literals
7-
)
5+
from __future__ import absolute_import, division, print_function, unicode_literals
86

97
from behave import given, then
108

@@ -15,31 +13,40 @@
1513

1614
# given ===================================================
1715

18-
@given('a Bookmarks object of length 5 as bookmarks')
16+
17+
@given("a Bookmarks object of length 5 as bookmarks")
1918
def given_a_Bookmarks_object_of_length_5_as_bookmarks(context):
20-
document = Document(test_docx('bmk-bookmarks'))
19+
document = Document(test_docx("bmk-bookmarks"))
2120
context.bookmarks = document.bookmarks
2221

2322

2423
# then =====================================================
2524

26-
@then('bookmarks[{idx}] is a _Bookmark object')
25+
26+
@then('bookmarks.get({name}) returns bookmark named "{name}" with id {id}')
27+
def then_bookmark_get_returns_bookmark_object(context, name, id):
28+
bookmark = context.bookmarks.get(name)
29+
assert bookmark.name == name
30+
assert bookmark.id == int(id)
31+
32+
33+
@then("bookmarks[{idx}] is a _Bookmark object")
2734
def then_bookmarks_idx_is_a_Bookmark_object(context, idx):
2835
item = context.bookmarks[int(idx)]
29-
expected = '_Bookmark'
36+
expected = "_Bookmark"
3037
actual = item.__class__.__name__
31-
assert actual == expected, 'bookmarks[%s] is a %s object' % (idx, actual)
38+
assert actual == expected, "bookmarks[%s] is a %s object" % (idx, actual)
3239

3340

34-
@then('iterating bookmarks produces {n} _Bookmark objects')
41+
@then("iterating bookmarks produces {n} _Bookmark objects")
3542
def then_iterating_bookmarks_produces_n_Bookmark_objects(context, n):
3643
items = [item for item in context.bookmarks]
3744
assert len(items) == int(n)
38-
assert all(item.__class__.__name__ == '_Bookmark' for item in items)
45+
assert all(item.__class__.__name__ == "_Bookmark" for item in items)
3946

4047

41-
@then('len(bookmarks) == {count}')
48+
@then("len(bookmarks) == {count}")
4249
def then_len_bookmarks_eq_count(context, count):
4350
expected = int(count)
4451
actual = len(context.bookmarks)
45-
assert actual == expected, 'len(bookmarks) == %s' % actual
52+
assert actual == expected, "len(bookmarks) == %s" % actual

0 commit comments

Comments
 (0)