@@ -59,6 +59,38 @@ def test_property_assignment_nested_array(self):
59
59
self .figure ._send_relayout_msg .assert_called_once_with (
60
60
{'updatemenus.1.buttons.0.method' : 'restyle' })
61
61
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
+
62
94
def test_plotly_relayout_toplevel (self ):
63
95
self .figure .plotly_relayout ({'title' : 'hello' })
64
96
self .figure ._send_relayout_msg .assert_called_once_with (
0 commit comments