diff options
author | Kapileshwar Singh <kpsingh@google.com> | 2016-07-13 19:31:40 +0200 |
---|---|---|
committer | Javi Merino <javi.merino@arm.com> | 2016-07-17 12:58:57 +0100 |
commit | fea80b84fa13a9c0ce75be7fe8c01151f813ee0f (patch) | |
tree | 5a248b525a5dbf998333714199dfd02e1c859252 /tests/test_plotter.py | |
parent | 5c53c1f76cb60be8cf1d6c43b54a3f04eae10d6c (diff) | |
download | trappy-fea80b84fa13a9c0ce75be7fe8c01151f813ee0f.tar.gz |
tests: add test for ILinePlotGen.df_to_dygraph
Change-Id: I85327148401972ec477fd6c43889a487bc8ae083
Diffstat (limited to 'tests/test_plotter.py')
-rw-r--r-- | tests/test_plotter.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/test_plotter.py b/tests/test_plotter.py index 139bea9..a24ad1e 100644 --- a/tests/test_plotter.py +++ b/tests/test_plotter.py @@ -292,6 +292,32 @@ class TestILinePlotter(unittest.TestCase): with self.assertRaises(ValueError): trappy.ILinePlot([dfr1, dfr2]).view(test=True) + def test_df_to_dygraph(self): + """Test the ILinePlot util function: df_to_dygraph""" + + dfr1 = pd.DataFrame([[1, 2], + [3, 4], + [5, 6]], + index=[0., 1., 2.], columns=["a", "b"]) + + dfr2 = pd.DataFrame([1, 2, 3, 4], + index=[0., 1., 2., 3.], columns=["a"]) + + expected_result_1 = { + 'labels': ['index', 'a', 'b'], + 'data': [[0.0, 1, 2], [1.0, 3, 4], [2.0, 5, 6]] + } + expected_result_2 = { + 'labels': ['index', 'a'], + 'data': [[0.0, 1], [1.0, 2], [2.0, 3], [3.0, 4]] + } + + result_1 = trappy.plotter.ILinePlotGen.df_to_dygraph(dfr1) + result_2 = trappy.plotter.ILinePlotGen.df_to_dygraph(dfr2) + + self.assertDictEqual(result_1, expected_result_1) + self.assertDictEqual(result_2, expected_result_2) + def test_duplicate_merging(self): dfr1 = pd.DataFrame([1, 2, 3, 4], index=[0., 0., 1., 2.], columns=["a"]) dfr2 = pd.DataFrame([2, 3, 4, 5], index=[1., 1., 1., 2.], columns=["a"]) |