def testtable_mentsfail(self): """Make the cameo code description""" exp = 'GDELT 1.0 does not have a mentions table.' with self.assertRaises(Exception) as context: checked = _tableinfo('ments', version=1) the_exception = context.exception return self.assertEqual(exp, str(the_exception))
def testtable_cameo(self): """Make the cameo code description""" tabs = pd.read_json(os.path.join(BASE_DIR, 'data', 'cameoCodes.json'), dtype={ 'cameoCode': 'str', "GoldsteinScale": np.float64 }) return self.assertEqual(_tableinfo('cameo').shape, tabs.shape)
def testtable_fail(self): """Make the cameo code description""" table = 'bobby' valid = [ 'cameo', 'events', 'gkg', 'vgkg', 'iatv', 'graph', 'ments', 'mentions', 'cloudviz', 'cloud vision', 'vision' ] exp = ('You entered "{}"; this is not a valid table name.' ' Choose from {}.'.format(table, ", ".join(valid))) with self.assertRaises(Exception) as context: checked = _tableinfo('bobby', version=1) the_exception = context.exception return self.assertEqual(exp, str(the_exception))
def schema(self,tablename): """ Parameters ---------- :param tablename: str Name of table to retrieve desired schema Returns ------- :return: dataframe pandas dataframe with schema """ return _tableinfo(table=tablename,version=self.version)
def testtable_iatv(self): """Make the cameo code description""" tabs = pd.read_csv(os.path.join(BASE_DIR, 'data', 'iatv.csv')) return self.assertTrue(tabs.equals(_tableinfo('iatv', version=2)))