forked from scanny/python-pptx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_api.py
79 lines (58 loc) · 2.46 KB
/
test_api.py
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# encoding: utf-8
"""
Test suite for pptx.api module
"""
from __future__ import absolute_import, print_function
import pytest
from pptx.api import Presentation
from pptx.parts.presentation import PresentationPart
from .unitutil.mock import call, property_mock
class DescribePresentation(object):
def it_knows_the_width_of_its_slides(self, slide_width_get_fixture):
prs, slide_width = slide_width_get_fixture
assert prs.slide_width == slide_width
def it_can_change_the_width_of_its_slides(
self, slide_width_set_fixture):
prs, slide_width, part_slide_width_ = slide_width_set_fixture
prs.slide_width = slide_width
assert part_slide_width_.mock_calls == [call(slide_width)]
def it_knows_the_height_of_its_slides(self, slide_height_get_fixture):
prs, slide_height = slide_height_get_fixture
assert prs.slide_height == slide_height
def it_can_change_the_height_of_its_slides(
self, slide_height_set_fixture):
prs, slide_height, part_slide_height_ = slide_height_set_fixture
prs.slide_height = slide_height
assert part_slide_height_.mock_calls == [call(slide_height)]
# fixtures -------------------------------------------------------
@pytest.fixture
def slide_height_get_fixture(self, part_slide_height_, slide_height):
prs = Presentation()
part_slide_height_.return_value = slide_height
return prs, slide_height
@pytest.fixture
def slide_height_set_fixture(self, part_slide_height_, slide_height):
prs = Presentation()
return prs, slide_height, part_slide_height_
@pytest.fixture
def slide_width_get_fixture(self, part_slide_width_, slide_width):
prs = Presentation()
part_slide_width_.return_value = slide_width
return prs, slide_width
@pytest.fixture
def slide_width_set_fixture(self, part_slide_width_, slide_width):
prs = Presentation()
return prs, slide_width, part_slide_width_
# fixtures components --------------------------------------------
@pytest.fixture
def part_slide_height_(self, request):
return property_mock(request, PresentationPart, 'slide_height')
@pytest.fixture
def part_slide_width_(self, request):
return property_mock(request, PresentationPart, 'slide_width')
@pytest.fixture
def slide_height(self):
return 7654321
@pytest.fixture
def slide_width(self):
return 9876543