class TestDemo(unittest.TestCase): def setUp(self): self.db = Postgresql() # (base_dir='data') self.conn = psycopg2.connect(**self.db.dsn()) self.cur = self.conn.cursor() self.pgdb = PostgresDemo(self.db.dsn()) def tearDown(self): self.db.stop() def test_pg_up(self): self.cur.execute(u"select version()") result = self.cur.fetchone() self.assertTrue(result) def test_create_foo(self): self.cur.execute(u"select exists(select * from information_schema." "tables where table_name={})".format("'foo'")) result = self.cur.fetchone()[0] self.assertTrue(result) def test_update(self): result = self.pgdb.update_fixture() self.assertEqual(result, 'fixed')
def setUp(self): self.db = Postgresql() # (base_dir='data') self.conn = psycopg2.connect(**self.db.dsn()) self.cur = self.conn.cursor() self.pgdb = PostgresDemo(self.db.dsn())