Skip to content
This repository has been archived by the owner on Sep 24, 2022. It is now read-only.

Commit

Permalink
Prevening tornado from logging (falsy) errors
Browse files Browse the repository at this point in the history
  • Loading branch information
haizaar committed Nov 30, 2015
1 parent de98f2f commit 7cc96cd
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ def test_request_queueing(self):
self.run_parallel_queries(self.pool_size*2)

def test_parallel_queries_after_reconnect_all(self):
"""Testing that pool still queries database in parallel after ALL connections were closeded"""
"""Testing that pool still queries database in parallel after ALL connections were closed"""
self.shutter(self.db)
self.run_parallel_queries()

Expand Down Expand Up @@ -815,14 +815,20 @@ def test_abort_waiting_queue(self):
@gen_test
def test_execute_can_start_before_connection_is_done(self):
db = momoko.Pool(dsn=self.good_dsn, size=1, ioloop=self.io_loop)
db.connect()
f = db.connect()
cursor = yield db.execute("SELECT 1")
self.assertEqual(cursor.fetchone()[0], 1)

# This is to hide tornado warnings about unconsumed futures
try:
yield f
except:
pass

@gen_test
def test_execute_before_connection_is_done_will_error(self):
db = momoko.Pool(dsn=bad_dsn, size=1, ioloop=self.io_loop)
db.connect()
f = db.connect()

try:
yield db.execute("SELECT 1")
Expand All @@ -833,6 +839,12 @@ def test_execute_before_connection_is_done_will_error(self):
except psycopg2.DatabaseError:
pass

# This is to hide tornado warnings about unconsumed futures
try:
yield f
except:
pass


class MomokoPoolVolatileDbTestProxy(ProxyMixIn, MomokoPoolVolatileDbTest):

Expand Down Expand Up @@ -869,15 +881,14 @@ def test_execute_can_fail_after_disconnect_with_no_reconnect(self):
# No start proxy here!
yield gen.sleep(db.reconnect_interval)
f2 = db.execute("SELECT 1")
f3 = db.execute("SELECT 1")

try:
yield [f2, f3]
yield f2
self.fail("Exception should have been raised")
except psycopg2.DatabaseError:
pass
self.assertEqual(len(db.conns.waiting_queue), 0)

self.assertEqual(len(db.conns.waiting_queue), 0)

class MomokoPoolPartiallyConnectedTest(PoolBaseTest):
raise_connect_errors = True
Expand Down

0 comments on commit 7cc96cd

Please sign in to comment.