def test_dict(self): ts_dict = get_time_series(self.keys_to_check[0]) self.assertTrue(type(ts_dict) is dict) self.assertEqual(ts_dict.keys()[0], self.keys_to_check[0]) self.assertTrue( type(ts_dict[self.keys_to_check[0]]) is pandas.core.series.Series)
def test_invalid_api_key(self): with self.assertRaisesRegexp(KofdataError, 'Could not authenticate'): get_time_series('doesntmatter', 'notakey')
def test_nonexistent_key(self): with self.assertRaisesRegexp(KofdataError, 'The API responded'): get_time_series('nonexistend_key')
def test_multiple_keys(self): ts = get_time_series(self.keys_to_check) self.assertEqual(len(ts), 2)
def test_df(self): ts_df = get_time_series(self.keys_to_check[0], as_data_frame=True) self.assertTrue(type(ts_df) is pandas.core.frame.DataFrame) self.assertEqual(ts_df.columns[0], self.keys_to_check[0])