def test_close_connection(self): foo = DB("bar") foo.conn = fake_connection() foo.close_connection() assert foo.conn is None
def test_query(self): foo = DB("bar") foo.conn = fake_connection() bar = foo.query("some query") assert bar == True assert foo.conn.called_execute == True
def test_insertupdate(self): foo = DB("bar") foo.conn = fake_connection() foo.insertupdate("some query", ["val1", "val2"]) assert foo.conn.called_close == False assert foo.conn.called_commit == True assert foo.conn.fake_cursor.called_execute == True
def test_execute(self): foo = DB("bar") foo.conn = fake_connection_2() foo.execute("fake query") assert foo.conn.called_close == False assert foo.conn.called_commit == True assert foo.conn.called_execute == False assert foo.conn.fake_cursor.called_execute == True
def test_insertupdate_catches_exception(self): foo = DB("bar") foo.conn = fake_failed_connection() bar = foo.insertupdate("some query", ["val1", "val2"]) assert bar == None