-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_convert_presentation.py
More file actions
61 lines (45 loc) · 2.1 KB
/
test_convert_presentation.py
File metadata and controls
61 lines (45 loc) · 2.1 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
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/python
# -*- coding: utf-8 -*-
import unittest
from pptx import Presentation
import convert_presentation
import time
class TestConvertPresentation(unittest.TestCase):
def setUp(self):
self._started_at = time.time()
def tearDown(self):
elapsed = time.time() - self._started_at
print('{} ({}s)'.format(self.id(), round(elapsed, 2)))
def test_read_number_of_slides(self):
prs = Presentation("tests/testinputs/CK20V2.pptx")
self.assertEqual(len(prs.slides), 104)
def test_name(self):
slide = Presentation("tests/testinputs/CK20V2.pptx").slides[0]
self.assertEqual(convert_presentation.get_name(slide), u"Top page")
def test_name2(self):
slide = Presentation("tests/testinputs/CK20V2.pptx").slides[2]
self.assertEqual(convert_presentation.get_name(slide), u"")
def test_inside(self):
slide = Presentation("tests/testinputs/CK20V2.pptx").slides[3]
shapeA=convert_presentation.hollow_shape(slide.shapes[1])
shapeB=convert_presentation.hollow_shape(slide.shapes[0])
self.assertEqual(True,convert_presentation.is_first_inside_second(shapeA,shapeB))
def test_outside(self):
slide = Presentation("tests/testinputs/CK20V2.pptx").slides[4]
shapeA=convert_presentation.hollow_shape(slide.shapes[1])
shapeB=convert_presentation.hollow_shape(slide.shapes[0])
self.assertEqual(False,convert_presentation.is_first_inside_second(shapeA,shapeB))
def test_how_many_shapes_arent_inside_in_order(self):
slide = Presentation("tests/testinputs/CK20V2.pptx").slides[2]
containers=convert_presentation.get_containers(slide)
self.assertEqual(20,len(containers))
def test_get_all_containers(self):
#mostly here for speed
containers=[]
for slide in Presentation("tests/testinputs/CK20V2.pptx").slides:
containers=convert_presentation.get_containers(slide)
self.assertEqual(23,len(containers))
#Todo - blank names
if __name__ == '__main__':
unittest.main()
pytest.main(__file__)