@@ -1126,6 +1126,114 @@ def test_table_with_index(self):
1126
1126
self .assertEqual (index_table , exp_index_table )
1127
1127
1128
1128
1129
+ class TestGantt (TestCase ):
1130
+
1131
+ def test_validate_gantt (self ):
1132
+
1133
+ # checks if gantt is of valid form
1134
+ df = [dict (Task = "Job A" )]
1135
+
1136
+ self .assertRaises (PlotlyError , tls .FigureFactory .create_gantt ,
1137
+ df )
1138
+
1139
+ df = [dict (Task = 'Job A' ,
1140
+ Start = '2009-02-01' ,
1141
+ Finish = '2009-08-30' ,
1142
+ Complete = 'a' )]
1143
+
1144
+ pattern2 = ("In order to use an indexing column and assign colors to "
1145
+ "the values of the index, you must choose an actual "
1146
+ "column name in the dataframe or key if a list of "
1147
+ "dictionaries is being used." )
1148
+
1149
+ self .assertRaisesRegexp (PlotlyError , pattern2 ,
1150
+ tls .FigureFactory .create_gantt ,
1151
+ df , index_col = 'foo' )
1152
+
1153
+ df = 'foo'
1154
+
1155
+ pattern3 = ("You must input either a dataframe or a list of "
1156
+ "dictionaries." )
1157
+
1158
+ self .assertRaisesRegexp (PlotlyError , pattern3 ,
1159
+ tls .FigureFactory .create_gantt , df )
1160
+
1161
+ df = []
1162
+
1163
+ pattern4 = ("Your list is empty. It must contain at least one "
1164
+ "dictionary." )
1165
+
1166
+ self .assertRaisesRegexp (PlotlyError , pattern4 ,
1167
+ tls .FigureFactory .create_gantt , df )
1168
+
1169
+ df = ['foo' ]
1170
+
1171
+ pattern5 = ("Your list must only include dictionaries." )
1172
+
1173
+ self .assertRaisesRegexp (PlotlyError , pattern5 ,
1174
+ tls .FigureFactory .create_gantt , df )
1175
+
1176
+ def test_gantt_index (self ):
1177
+
1178
+ df = [dict (Task = 'Job A' ,
1179
+ Start = '2009-02-01' ,
1180
+ Finish = '2009-08-30' ,
1181
+ Complete = 50 )]
1182
+
1183
+ pattern = ("In order to use an indexing column and assign colors to "
1184
+ "the values of the index, you must choose an actual "
1185
+ "column name in the dataframe or key if a list of "
1186
+ "dictionaries is being used." )
1187
+
1188
+ self .assertRaisesRegexp (PlotlyError , pattern ,
1189
+ tls .FigureFactory .create_gantt ,
1190
+ df , index_col = 'foo' )
1191
+
1192
+ df = [dict (Task = 'Job A' , Start = '2009-02-01' ,
1193
+ Finish = '2009-08-30' , Complete = 'a' ),
1194
+ dict (Task = 'Job A' , Start = '2009-02-01' ,
1195
+ Finish = '2009-08-30' , Complete = 50 )]
1196
+
1197
+ pattern2 = ("Error in indexing column. Make sure all entries of each "
1198
+ "column are all numbers or all strings." )
1199
+
1200
+ self .assertRaisesRegexp (PlotlyError , pattern2 ,
1201
+ tls .FigureFactory .create_gantt ,
1202
+ df , index_col = 'Complete' )
1203
+
1204
+ def test_gantt_validate_colors (self ):
1205
+
1206
+ df = [dict (Task = 'Job A' , Start = '2009-02-01' ,
1207
+ Finish = '2009-08-30' , Complete = 75 ),
1208
+ dict (Task = 'Job B' , Start = '2009-02-01' ,
1209
+ Finish = '2009-08-30' , Complete = 50 )]
1210
+
1211
+ pattern = ("Whoops! The elements in your rgb colors tuples cannot "
1212
+ "exceed 255.0." )
1213
+
1214
+ self .assertRaisesRegexp (PlotlyError , pattern ,
1215
+ tls .FigureFactory .create_gantt , df ,
1216
+ index_col = 'Complete' , colors = 'rgb(300,1,1)' )
1217
+
1218
+ self .assertRaises (PlotlyError , tls .FigureFactory .create_gantt ,
1219
+ df , index_col = 'Complete' , colors = 'foo' )
1220
+
1221
+ pattern2 = ("Whoops! The elements in your colors tuples cannot "
1222
+ "exceed 1.0." )
1223
+
1224
+ self .assertRaisesRegexp (PlotlyError , pattern2 ,
1225
+ tls .FigureFactory .create_gantt , df ,
1226
+ index_col = 'Complete' , colors = (2 , 1 , 1 ))
1227
+
1228
+ pattern3 = ("You must input a valid colors. Valid types include a "
1229
+ "plotly scale, rgb, hex or tuple color, a list of any "
1230
+ "color types, or a dictionary with index names each "
1231
+ "assigned to a color." )
1232
+
1233
+ self .assertRaisesRegexp (PlotlyError , pattern3 ,
1234
+ tls .FigureFactory .create_gantt , df ,
1235
+ index_col = 'Complete' , colors = 5 )
1236
+
1129
1237
# class TestDistplot(TestCase):
1130
1238
1131
1239
# def test_scipy_import_error(self):
0 commit comments