Skip to content

Commit 43ae1d0

Browse files
committed
finished tests and added comment for 512 height, width defaults
1 parent abb4178 commit 43ae1d0

File tree

2 files changed

+39
-36
lines changed

2 files changed

+39
-36
lines changed

plotly/presentation_objs/presentation_objs.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def list_of_options(iterable, conj='and', period=True):
6363
template = (len(iterable) - 2)*'{}, ' + '{} ' + conj + ' {}' + period*'.'
6464
return template.format(*iterable)
6565

66+
6667
# Error Messages
6768
STYLE_ERROR = "Your presentation style must be {}".format(
6869
list_of_options(PRES_THEMES, conj='or', period=True)
@@ -88,6 +89,7 @@ def list_of_options(iterable, conj='and', period=True):
8889
)
8990
)
9091

92+
9193
def _generate_id(size):
9294
letters_and_numbers = string.ascii_letters
9395
for num in range(10):
@@ -208,6 +210,8 @@ def _box(boxtype, text_or_url, left, top, height, width, id, props_attr,
208210
)
209211

210212
elif boxtype == 'Image':
213+
# height, width are set to default 512
214+
# as set by the Presentation Editor
211215
props = {
212216
'height': 512,
213217
'imageName': None,
@@ -1017,8 +1021,10 @@ def _markdown_to_presentation(self, markdown_string, style, imgStretch):
10171021

10181022
(specs_for_boxes, specs_for_title, specs_for_text, bkgd_color,
10191023
title_style_attr, text_style_attr,
1020-
code_theme) = _return_layout_specs(num_of_boxes, url_lines,
1021-
title_lines, text_block, code_blocks, slide_num, style)
1024+
code_theme) = _return_layout_specs(
1025+
num_of_boxes, url_lines, title_lines, text_block, code_blocks,
1026+
slide_num, style
1027+
)
10221028

10231029
# background color
10241030
self._color_background(bkgd_color, slide_num)

plotly/tests/test_core/test_spectacle_presentation/test_spectacle_presentation.py

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -53,37 +53,10 @@ def test_invalid_code_language(self):
5353

5454

5555
def test_expected_pres(self):
56-
md_string = """
57-
# title
58-
---
59-
transition: zoom, fade, fade
60-
# Colors
61-
Colors are everywhere around us.
62-
Plotly(https://plot.ly/~AdamKulidjian/3564/)
63-
Image(https://raw.githubusercontent.com/jackparmer/gradient-backgrounds/master/moods1.png)
64-
```python
65-
x=1
66-
```
67-
---
68-
Plotly(https://plot.ly/~AdamKulidjian/3564/)
69-
Plotly(https://plot.ly/~AdamKulidjian/3564/)
70-
Plotly(https://plot.ly/~AdamKulidjian/3564/)
71-
Plotly(https://plot.ly/~AdamKulidjian/3564/)
72-
Plotly(https://plot.ly/~AdamKulidjian/3564/)
73-
Plotly(https://plot.ly/~AdamKulidjian/3564/)
74-
Plotly(https://plot.ly/~AdamKulidjian/3564/)
75-
---
76-
"""
77-
78-
markdown_string = """
79-
# things
80-
happy happy joy joy
81-
---
82-
# yes
83-
"""
56+
markdown_string = "# title\n---\ntransition: zoom, fade, fade\n# Colors\nColors are everywhere around us.\nPlotly(https://plot.ly/~AdamKulidjian/3564/)\nImage(https://raw.githubusercontent.com/jackparmer/gradient-backgrounds/master/moods1.png)\n```python\nx=1\n```\n---\nPlotly(https://plot.ly/~AdamKulidjian/3564/)\nPlotly(https://plot.ly/~AdamKulidjian/3564/)\nPlotly(https://plot.ly/~AdamKulidjian/3564/)\nPlotly(https://plot.ly/~AdamKulidjian/3564/)\nPlotly(https://plot.ly/~AdamKulidjian/3564/)\nPlotly(https://plot.ly/~AdamKulidjian/3564/)\nPlotly(https://plot.ly/~AdamKulidjian/3564/)\n---\n"
8457

8558
my_pres = pres.Presentation(
86-
md_string, style='moods', imgStretch=False
59+
markdown_string, style='moods', imgStretch=False
8760
)
8861

8962
exp_pres = {'presentation': {'paragraphStyles': {'Body': {'color': '#000016',
@@ -358,9 +331,33 @@ def test_expected_pres(self):
358331
exp_pres['presentation'][k]
359332
)
360333

361-
#self.assertEqual(
362-
# my_pres['presentation']['slides'][0],
363-
# exp_pres['presentation']['slides'][0]
364-
#)
334+
self.assertEqual(
335+
len(my_pres['presentation']['slides']),
336+
len(exp_pres['presentation']['slides'])
337+
)
338+
339+
for slide_idx in range(len(my_pres['presentation']['slides'])):
340+
childs = my_pres['presentation']['slides'][slide_idx]['children']
341+
# transitions and background color
342+
self.assertEqual(
343+
my_pres['presentation']['slides'][slide_idx]['props'],
344+
exp_pres['presentation']['slides'][slide_idx]['props']
345+
)
346+
for child_idx in range(len(childs)):
347+
# check urls
348+
if (my_pres['presentation']['slides'][slide_idx]['children']
349+
[child_idx]['type'] in ['Image', 'Plotly']):
350+
self.assertEqual(
351+
(my_pres['presentation']['slides'][slide_idx]
352+
['children'][child_idx]['props']),
353+
(exp_pres['presentation']['slides'][slide_idx]
354+
['children'][child_idx]['props'])
355+
)
365356

366-
self.assertEqual(len(my_pres['presentation']['slides']), 1)
357+
# styles in children
358+
self.assertEqual(
359+
(my_pres['presentation']['slides'][slide_idx]
360+
['children'][child_idx]['props']),
361+
(exp_pres['presentation']['slides'][slide_idx]
362+
['children'][child_idx]['props'])
363+
)

0 commit comments

Comments
 (0)