@@ -75,6 +75,88 @@ def test_capitalize_after_underscore(self):
75
75
self .assertEqual (string_to_class_name (object_name ), class_name )
76
76
77
77
78
+ class TestObjectNameToClassName (TestCase ):
79
+
80
+ def test_backwards_compat (self ):
81
+
82
+ # Old classes should still be shown to users.
83
+
84
+ test_tuples = [
85
+ ('angularaxis' , 'AngularAxis' ),
86
+ ('annotation' , 'Annotation' ),
87
+ ('annotations' , 'Annotations' ),
88
+ ('area' , 'Area' ),
89
+ ('colorbar' , 'ColorBar' ),
90
+ ('contour' , 'Contour' ),
91
+ ('contours' , 'Contours' ),
92
+ ('data' , 'Data' ),
93
+ ('error_x' , 'ErrorX' ),
94
+ ('error_y' , 'ErrorY' ),
95
+ ('error_z' , 'ErrorZ' ),
96
+ ('figure' , 'Figure' ),
97
+ ('font' , 'Font' ),
98
+ ('layout' , 'Layout' ),
99
+ ('legend' , 'Legend' ),
100
+ ('margin' , 'Margin' ),
101
+ ('marker' , 'Marker' ),
102
+ ('radialaxis' , 'RadialAxis' ),
103
+ ('scene' , 'Scene' ),
104
+ ('stream' , 'Stream' ),
105
+ ('xaxis' , 'XAxis' ),
106
+ ('xbins' , 'XBins' ),
107
+ ('yaxis' , 'YAxis' ),
108
+ ('ybins' , 'YBins' ),
109
+ ('zaxis' , 'ZAxis' )
110
+ ]
111
+
112
+ for object_name , expected_class_name in test_tuples :
113
+ class_name = gr .object_name_to_class_name (object_name )
114
+ msg = (object_name , expected_class_name , class_name )
115
+ self .assertEqual (class_name , expected_class_name , msg = msg )
116
+
117
+ def test_old_traces (self ):
118
+
119
+ # While the old trace classes exist, the newer should be returned.
120
+
121
+ test_tuples = [
122
+ ('histogram2dcontour' , 'Histogram2dcontour' )
123
+ ]
124
+
125
+ for object_name , expected_class_name in test_tuples :
126
+ class_name = gr .object_name_to_class_name (object_name )
127
+ msg = (object_name , expected_class_name , class_name )
128
+ self .assertEqual (class_name , expected_class_name , msg = msg )
129
+
130
+ def test_new_traces (self ):
131
+
132
+ # New traces should get have classes defined.
133
+
134
+ test_tuples = [
135
+ ('choropleth' , 'Choropleth' ),
136
+ ('pie' , 'Pie' )
137
+ ]
138
+
139
+ for object_name , expected_class_name in test_tuples :
140
+ class_name = gr .object_name_to_class_name (object_name )
141
+ msg = (object_name , expected_class_name , class_name )
142
+ self .assertEqual (class_name , expected_class_name , msg = msg )
143
+
144
+ def test_new_non_trace_objects (self ):
145
+
146
+ # New objects get 'dict' or 'list'.
147
+
148
+ test_tuples = [
149
+ ('geo' , 'dict' ),
150
+ ('shapes' , 'list' ),
151
+ ('shape' , 'dict' ),
152
+ ]
153
+
154
+ for object_name , expected_class_name in test_tuples :
155
+ class_name = gr .object_name_to_class_name (object_name )
156
+ msg = (object_name , expected_class_name , class_name )
157
+ self .assertEqual (class_name , expected_class_name , msg = msg )
158
+
159
+
78
160
class TestGetAttributesMethods (TestCase ):
79
161
80
162
def test_get_subplot_attributes (self ):
0 commit comments