def test_mvam_raises_error_if_wrong_table_provided(self): ''' mVAM().query() raises error if incorrect table requested. ''' with self.assertRaises(ValueError): mVAM(table='foo').query()
def test_mvam_query_returns_a_list(self): ''' mVAM().query() returns a list of results. ''' result = mVAM().query() self.assertIs(type(result), list) result = mVAM().query(statement="ADM0_NAME='Yemen' AND VARIABLE='FCS' AND MEAN < 40") self.assertIs(type(result), list)
def test_mvam_metadata_is_dictionary(self): ''' mVAM().metadata is a dictionary. ''' result = mVAM().metadata self.assertIs(type(result), dict)
def main(): """ Program wrapper. """ tables = ["pblStatsSum", "pblStatsSum4Maps"] for t in tables: m = mVAM(table=t) output = [] records = m.query() for record in records: output.append(parse(record)) store_csv(data=output, path="%s.csv" % t) store_sqlite(data=output, table=t)