File tree Expand file tree Collapse file tree 2 files changed +3
-14
lines changed
tests/test_core/test_tools Expand file tree Collapse file tree 2 files changed +3
-14
lines changed Original file line number Diff line number Diff line change @@ -1130,12 +1130,6 @@ class TestGantt(TestCase):
1130
1130
1131
1131
def test_validate_gantt (self ):
1132
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
1133
df = [dict (Task = 'Job A' ,
1140
1134
Start = '2009-02-01' ,
1141
1135
Finish = '2009-08-30' ,
Original file line number Diff line number Diff line change @@ -1457,8 +1457,8 @@ def _validate_gantt(df):
1457
1457
"""
1458
1458
Validates the inputted dataframe or list
1459
1459
"""
1460
- if isinstance (df , pd .core .frame .DataFrame ):
1461
- # validate if df is a dataframe
1460
+ if _pandas_imported and isinstance (df , pd .core .frame .DataFrame ):
1461
+ # validate that df has all the required keys
1462
1462
for key in REQ_GANTT_KEYS :
1463
1463
if key not in df :
1464
1464
raise exceptions .PlotlyError ("The columns in your data"
@@ -1479,19 +1479,14 @@ def _validate_gantt(df):
1479
1479
if not isinstance (df , list ):
1480
1480
raise exceptions .PlotlyError ("You must input either a dataframe "
1481
1481
"or a list of dictionaries." )
1482
+
1482
1483
# validate if df is empty
1483
1484
if len (df ) <= 0 :
1484
1485
raise exceptions .PlotlyError ("Your list is empty. It must contain "
1485
1486
"at least one dictionary." )
1486
1487
if not isinstance (df [0 ], dict ):
1487
1488
raise exceptions .PlotlyError ("Your list must only "
1488
1489
"include dictionaries." )
1489
- for key in REQ_GANTT_KEYS :
1490
- for dictionary in df :
1491
- if key not in dictionary :
1492
- raise exceptions .PlotlyError ("The columns in your data"
1493
- "frame must be one "
1494
- "of" .format (REQ_GANTT_KEYS ))
1495
1490
return df
1496
1491
1497
1492
@staticmethod
You can’t perform that action at this time.
0 commit comments