|
2 | 2 |
|
3 | 3 | """Step implementations for bookmark-related features."""
|
4 | 4 |
|
5 |
| -from __future__ import ( |
6 |
| - absolute_import, division, print_function, unicode_literals |
7 |
| -) |
| 5 | +from __future__ import absolute_import, division, print_function, unicode_literals |
8 | 6 |
|
9 | 7 | from behave import given, then
|
10 | 8 |
|
|
15 | 13 |
|
16 | 14 | # given ===================================================
|
17 | 15 |
|
18 |
| -@given('a Bookmarks object of length 5 as bookmarks') |
| 16 | + |
| 17 | +@given("a Bookmarks object of length 5 as bookmarks") |
19 | 18 | 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")) |
21 | 20 | context.bookmarks = document.bookmarks
|
22 | 21 |
|
23 | 22 |
|
24 | 23 | # then =====================================================
|
25 | 24 |
|
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") |
27 | 34 | def then_bookmarks_idx_is_a_Bookmark_object(context, idx):
|
28 | 35 | item = context.bookmarks[int(idx)]
|
29 |
| - expected = '_Bookmark' |
| 36 | + expected = "_Bookmark" |
30 | 37 | 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) |
32 | 39 |
|
33 | 40 |
|
34 |
| -@then('iterating bookmarks produces {n} _Bookmark objects') |
| 41 | +@then("iterating bookmarks produces {n} _Bookmark objects") |
35 | 42 | def then_iterating_bookmarks_produces_n_Bookmark_objects(context, n):
|
36 | 43 | items = [item for item in context.bookmarks]
|
37 | 44 | 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) |
39 | 46 |
|
40 | 47 |
|
41 |
| -@then('len(bookmarks) == {count}') |
| 48 | +@then("len(bookmarks) == {count}") |
42 | 49 | def then_len_bookmarks_eq_count(context, count):
|
43 | 50 | expected = int(count)
|
44 | 51 | actual = len(context.bookmarks)
|
45 |
| - assert actual == expected, 'len(bookmarks) == %s' % actual |
| 52 | + assert actual == expected, "len(bookmarks) == %s" % actual |
0 commit comments