Skip to content

Commit

Permalink
Add test to make sure various template assignments trigger relayout m…
Browse files Browse the repository at this point in the history
…essages
  • Loading branch information
jonmmease committed Oct 7, 2018
1 parent 08e095b commit f84c8a5
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,38 @@ def test_property_assignment_nested_array(self):
self.figure._send_relayout_msg.assert_called_once_with(
{'updatemenus.1.buttons.0.method': 'restyle'})

def test_property_assignment_template(self):
# Initialize template object
self.figure.layout.template = {'layout': {
'xaxis': {'title': 'x-label'}}}
self.figure._send_relayout_msg.assert_called_with(
{'template': {'layout': {'xaxis': {'title': 'x-label'}}}})

# template layout property
self.figure.layout.template.layout.title = 'Template Title'
self.figure._send_relayout_msg.assert_called_with(
{'template.layout.title': 'Template Title'})

# template add trace
self.figure.layout.template.data = {'bar': [
{'marker': {'color': 'blue'}},
{'marker': {'color': 'yellow'}}]}

self.figure._send_relayout_msg.assert_called_with(
{'template.data': {'bar': [
{'type': 'bar', 'marker': {'color': 'blue'}},
{'type': 'bar', 'marker': {'color': 'yellow'}}]}})

# template set trace property
self.figure.layout.template.data.bar[1].marker.opacity = 0.5
self.figure._send_relayout_msg.assert_called_with(
{'template.data.bar.1.marker.opacity': 0.5})

# Set elementdefaults property
self.figure.layout.template.layout.imagedefaults.sizex = 300
self.figure._send_relayout_msg.assert_called_with(
{'template.layout.imagedefaults.sizex': 300})

def test_plotly_relayout_toplevel(self):
self.figure.plotly_relayout({'title': 'hello'})
self.figure._send_relayout_msg.assert_called_once_with(
Expand Down

0 comments on commit f84c8a5

Please sign in to comment.