-
Notifications
You must be signed in to change notification settings - Fork 551
/
Copy pathtest_api.py
48 lines (35 loc) · 1.41 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
"""Unit-test suite for `pptx.api` module."""
from __future__ import annotations
import os
import pytest
import pptx
from pptx.api import Presentation
from pptx.opc.constants import CONTENT_TYPE as CT
from pptx.parts.presentation import PresentationPart
from .unitutil.mock import class_mock, instance_mock
class DescribePresentation(object):
def it_opens_default_template_on_no_path_provided(self, call_fixture):
Package_, path, prs_ = call_fixture
prs = Presentation()
Package_.open.assert_called_once_with(path)
assert prs is prs_
# fixtures -------------------------------------------------------
@pytest.fixture
def call_fixture(self, Package_, prs_, prs_part_):
path = os.path.abspath(
os.path.join(os.path.split(pptx.__file__)[0], "templates", "default.pptx")
)
Package_.open.return_value.main_document_part = prs_part_
prs_part_.content_type = CT.PML_PRESENTATION_MAIN
prs_part_.presentation = prs_
return Package_, path, prs_
# fixture components ---------------------------------------------
@pytest.fixture
def Package_(self, request):
return class_mock(request, "pptx.api.Package")
@pytest.fixture
def prs_(self, request):
return instance_mock(request, Presentation)
@pytest.fixture
def prs_part_(self, request):
return instance_mock(request, PresentationPart)