def test_agg_week_hours(self): dummy = dummy_ct1() df = read_ct1(dummy, as_df=True) from matplotlib import pyplot as plt _, ax = plt.subplots(1, 1) plot_aggregated_ts(df, ax=ax, value='ITPRICE', agg='weekhour') plt.close('all')
def test_agg_raise(self): dummy = dummy_ct1() df = read_ct1(dummy, as_df=True) from matplotlib import pyplot as plt _, ax = plt.subplots(1, 1) self.assertRaise( lambda: plot_aggregated_ts(df, ax=ax, value='ITPRICE', agg='year_' ), ValueError) plt.close('all')
def test_ct1(self): dummy = dummy_ct1() res = read_ct1(dummy, as_df=False) self.assertIsInstance(res, list) self.assertEqual(len(res), 5) obs = res[0] self.assertEqual(len(obs['data']), 5) try: self.assertEqual(TestCt1.exp, obs) except AssertionError as e: raise AssertionError(pprint.pformat(obs)) from e
def test_cli(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") st = BufferedPrint() main(args=["read_folder", "--help"], fLOG=st.fprint) res = str(st) self.assertIn("usage: read_folder", res) st = BufferedPrint() fold = os.path.dirname(dummy_ct1()) temp = get_temp_folder(__file__, "temp_cli") dest = os.path.join(temp, "example.xlsx") main(args=["read_folder", "-f", fold, '-r', 'ct1', '--out', dest], fLOG=st.fprint) res = str(st) self.assertExists(dest)
def test_ct1_folder_df(self): dummy = dummy_ct1() fold = os.path.dirname(dummy) res1 = read_ct1(dummy, as_df=True) res2 = read_folder(fold, lambda f: read_ct1(f, as_df=True)) self.assertEqual(res1, res2)
def test_ct1_df(self): dummy = dummy_ct1() res = read_ct1(dummy, as_df=True) if __name__ == "__main__": res.T.to_excel("temp_test.xlsx") self.assertEqual(res.shape, (22, 43))