Skip to content

Commit f165b73

Browse files
committed
Updated tests
1 parent 7ac7d9b commit f165b73

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

plotly/tests/test_core/test_tools/test_figure_factory.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,12 +1130,6 @@ class TestGantt(TestCase):
11301130

11311131
def test_validate_gantt(self):
11321132

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-
11391133
df = [dict(Task='Job A',
11401134
Start='2009-02-01',
11411135
Finish='2009-08-30',

plotly/tools.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,8 +1457,8 @@ def _validate_gantt(df):
14571457
"""
14581458
Validates the inputted dataframe or list
14591459
"""
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
14621462
for key in REQ_GANTT_KEYS:
14631463
if key not in df:
14641464
raise exceptions.PlotlyError("The columns in your data"
@@ -1479,19 +1479,14 @@ def _validate_gantt(df):
14791479
if not isinstance(df, list):
14801480
raise exceptions.PlotlyError("You must input either a dataframe "
14811481
"or a list of dictionaries.")
1482+
14821483
# validate if df is empty
14831484
if len(df) <= 0:
14841485
raise exceptions.PlotlyError("Your list is empty. It must contain "
14851486
"at least one dictionary.")
14861487
if not isinstance(df[0], dict):
14871488
raise exceptions.PlotlyError("Your list must only "
14881489
"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))
14951490
return df
14961491

14971492
@staticmethod

0 commit comments

Comments
 (0)