forked from openlp/openlp
Fix a powerpoint test and make it run on all platforms.
This commit is contained in:
parent
47acc9dc89
commit
51b37de551
@ -164,45 +164,42 @@ class TestPowerpointDocument(TestCase, TestMixin):
|
|||||||
"""
|
"""
|
||||||
Test creating the titles from PowerPoint
|
Test creating the titles from PowerPoint
|
||||||
"""
|
"""
|
||||||
if is_win() and self.real_controller.check_available():
|
# GIVEN: mocked save_titles_and_notes, _get_text_from_shapes and two mocked slides
|
||||||
# GIVEN: mocked save_titles_and_notes, _get_text_from_shapes and two mocked slides
|
self.doc = PowerpointDocument(self.mock_controller, self.file_name)
|
||||||
self.doc = PowerpointDocument(self.real_controller, self.file_name)
|
self.doc.get_slide_count = MagicMock()
|
||||||
self.doc.save_titles_and_notes = MagicMock()
|
self.doc.get_slide_count.return_value = 2
|
||||||
self.doc._PowerpointDocument__get_text_from_shapes = MagicMock()
|
self.doc.index_map = {1: 1, 2: 2}
|
||||||
slide = MagicMock()
|
self.doc.save_titles_and_notes = MagicMock()
|
||||||
slide.Shapes.Title.TextFrame.TextRange.Text = 'SlideText'
|
self.doc._PowerpointDocument__get_text_from_shapes = MagicMock()
|
||||||
pres = MagicMock()
|
slide = MagicMock()
|
||||||
pres.Slides = [slide, slide]
|
slide.Shapes.Title.TextFrame.TextRange.Text = 'SlideText'
|
||||||
self.doc.presentation = pres
|
pres = MagicMock()
|
||||||
|
pres.Slides = MagicMock(side_effect=[slide, slide])
|
||||||
|
self.doc.presentation = pres
|
||||||
|
|
||||||
# WHEN reading the titles and notes
|
# WHEN reading the titles and notes
|
||||||
self.doc.create_titles_and_notes()
|
self.doc.create_titles_and_notes()
|
||||||
|
|
||||||
# THEN the save should have been called exactly once with 2 titles and 2 notes
|
# THEN the save should have been called exactly once with 2 titles and 2 notes
|
||||||
self.doc.save_titles_and_notes.assert_called_once_with(['SlideText\n', 'SlideText\n'], [' ', ' '])
|
self.doc.save_titles_and_notes.assert_called_once_with(['SlideText\n', 'SlideText\n'], [' ', ' '])
|
||||||
else:
|
|
||||||
self.skipTest('Powerpoint not available, skipping test.')
|
|
||||||
|
|
||||||
def create_titles_and_notes_with_no_slides_test(self):
|
def create_titles_and_notes_with_no_slides_test(self):
|
||||||
"""
|
"""
|
||||||
Test creating the titles from PowerPoint when it returns no slides
|
Test creating the titles from PowerPoint when it returns no slides
|
||||||
"""
|
"""
|
||||||
if is_win() and self.real_controller.check_available():
|
# GIVEN: mocked save_titles_and_notes, _get_text_from_shapes and two mocked slides
|
||||||
# GIVEN: mocked save_titles_and_notes, _get_text_from_shapes and two mocked slides
|
doc = PowerpointDocument(self.mock_controller, self.file_name)
|
||||||
doc = PowerpointDocument(self.real_controller, self.file_name)
|
doc.save_titles_and_notes = MagicMock()
|
||||||
doc.save_titles_and_notes = MagicMock()
|
doc._PowerpointDocument__get_text_from_shapes = MagicMock()
|
||||||
doc._PowerpointDocument__get_text_from_shapes = MagicMock()
|
pres = MagicMock()
|
||||||
pres = MagicMock()
|
pres.Slides = []
|
||||||
pres.Slides = []
|
doc.presentation = pres
|
||||||
doc.presentation = pres
|
|
||||||
|
|
||||||
# WHEN reading the titles and notes
|
# WHEN reading the titles and notes
|
||||||
doc.create_titles_and_notes()
|
doc.create_titles_and_notes()
|
||||||
|
|
||||||
# THEN the save should have been called exactly once with empty titles and notes
|
# THEN the save should have been called exactly once with empty titles and notes
|
||||||
doc.save_titles_and_notes.assert_called_once_with([], [])
|
doc.save_titles_and_notes.assert_called_once_with([], [])
|
||||||
else:
|
|
||||||
self.skipTest('Powerpoint not available, skipping test.')
|
|
||||||
|
|
||||||
def get_text_from_shapes_test(self):
|
def get_text_from_shapes_test(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user