Skip to content

Commit f84c8a5

Browse files
committed
Add test to make sure various template assignments trigger relayout messages
1 parent 08e095b commit f84c8a5

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Diff for: plotly/tests/test_core/test_figure_messages/test_plotly_relayout.py

+32
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,38 @@ def test_property_assignment_nested_array(self):
5959
self.figure._send_relayout_msg.assert_called_once_with(
6060
{'updatemenus.1.buttons.0.method': 'restyle'})
6161

62+
def test_property_assignment_template(self):
63+
# Initialize template object
64+
self.figure.layout.template = {'layout': {
65+
'xaxis': {'title': 'x-label'}}}
66+
self.figure._send_relayout_msg.assert_called_with(
67+
{'template': {'layout': {'xaxis': {'title': 'x-label'}}}})
68+
69+
# template layout property
70+
self.figure.layout.template.layout.title = 'Template Title'
71+
self.figure._send_relayout_msg.assert_called_with(
72+
{'template.layout.title': 'Template Title'})
73+
74+
# template add trace
75+
self.figure.layout.template.data = {'bar': [
76+
{'marker': {'color': 'blue'}},
77+
{'marker': {'color': 'yellow'}}]}
78+
79+
self.figure._send_relayout_msg.assert_called_with(
80+
{'template.data': {'bar': [
81+
{'type': 'bar', 'marker': {'color': 'blue'}},
82+
{'type': 'bar', 'marker': {'color': 'yellow'}}]}})
83+
84+
# template set trace property
85+
self.figure.layout.template.data.bar[1].marker.opacity = 0.5
86+
self.figure._send_relayout_msg.assert_called_with(
87+
{'template.data.bar.1.marker.opacity': 0.5})
88+
89+
# Set elementdefaults property
90+
self.figure.layout.template.layout.imagedefaults.sizex = 300
91+
self.figure._send_relayout_msg.assert_called_with(
92+
{'template.layout.imagedefaults.sizex': 300})
93+
6294
def test_plotly_relayout_toplevel(self):
6395
self.figure.plotly_relayout({'title': 'hello'})
6496
self.figure._send_relayout_msg.assert_called_once_with(

0 commit comments

Comments
 (0)