Skip to content

Commit

Permalink
yapf reformatting of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gmr committed Apr 29, 2015
1 parent 6f8c538 commit 4528a1a
Show file tree
Hide file tree
Showing 22 changed files with 333 additions and 490 deletions.
23 changes: 7 additions & 16 deletions tests/acceptance/async_test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ def begin(self, channel):
raise AssertionError("AsyncTestCase.begin_test not extended")

def start(self):
self.connection = self.ADAPTER(PARAMETERS,
self.on_open,
self.on_open_error,
self.on_closed)
self.connection = self.ADAPTER(PARAMETERS, self.on_open,
self.on_open_error, self.on_closed)
self.timeout = self.connection.add_timeout(self.TIMEOUT,
self.on_timeout)
self.connection.ioloop.start()
Expand Down Expand Up @@ -67,13 +65,10 @@ def on_timeout(self):


class BoundQueueTestCase(AsyncTestCase):

def tearDown(self):
"""Cleanup auto-declared queue and exchange"""
self._cconn = self.ADAPTER(PARAMETERS,
self._on_cconn_open,
self._on_cconn_error,
self._on_cconn_closed)
self._cconn = self.ADAPTER(PARAMETERS, self._on_cconn_open,
self._on_cconn_error, self._on_cconn_closed)

def start(self):
self.exchange = 'e' + str(id(self))
Expand All @@ -82,16 +77,14 @@ def start(self):
super(BoundQueueTestCase, self).start()

def begin(self, channel):
self.channel.exchange_declare(self.on_exchange_declared,
self.exchange,
self.channel.exchange_declare(self.on_exchange_declared, self.exchange,
exchange_type='direct',
passive=False,
durable=False,
auto_delete=True)

def on_exchange_declared(self, frame):
self.channel.queue_declare(self.on_queue_declared,
self.queue,
self.channel.queue_declare(self.on_queue_declared, self.queue,
passive=False,
durable=False,
exclusive=True,
Expand All @@ -100,9 +93,7 @@ def on_exchange_declared(self, frame):
arguments={'x-expires': self.TIMEOUT})

def on_queue_declared(self, frame):
self.channel.queue_bind(self.on_ready,
self.queue,
self.exchange,
self.channel.queue_bind(self.on_ready, self.queue, self.exchange,
self.routing_key)

def on_ready(self, frame):
Expand Down
39 changes: 8 additions & 31 deletions tests/acceptance/asyncore_adapter_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def start_test(self):


class TestConfirmSelect(AsyncTestCase):

def begin(self, channel):
channel._on_selectok = self.on_complete
channel.confirm_delivery()
Expand All @@ -47,8 +46,7 @@ class TestExchangeDeclareAndDelete(AsyncTestCase):

def begin(self, channel):
self.name = self.__class__.__name__ + ':' + str(id(self))
channel.exchange_declare(self.on_exchange_declared,
self.name,
channel.exchange_declare(self.on_exchange_declared, self.name,
exchange_type=self.X_TYPE,
passive=False,
durable=False,
Expand All @@ -75,14 +73,12 @@ class TestExchangeRedeclareWithDifferentValues(AsyncTestCase):
def begin(self, channel):
self.name = self.__class__.__name__ + ':' + str(id(self))
self.channel.add_on_close_callback(self.on_channel_closed)
channel.exchange_declare(self.on_exchange_declared,
self.name,
channel.exchange_declare(self.on_exchange_declared, self.name,
exchange_type=self.X_TYPE1,
passive=False,
durable=False,
auto_delete=True)


def on_cleanup_channel(self, channel):
channel.exchange_delete(None, self.name, nowait=True)
self.stop()
Expand All @@ -91,8 +87,7 @@ def on_channel_closed(self, channel, reply_code, reply_text):
self.connection.channel(self.on_cleanup_channel)

def on_exchange_declared(self, frame):
self.channel.exchange_declare(self.on_exchange_declared,
self.name,
self.channel.exchange_declare(self.on_exchange_declared, self.name,
exchange_type=self.X_TYPE2,
passive=False,
durable=False,
Expand All @@ -110,7 +105,6 @@ def start_test(self):


class TestQueueDeclareAndDelete(AsyncTestCase):

def begin(self, channel):
channel.queue_declare(self.on_queue_declared,
passive=False,
Expand All @@ -134,7 +128,6 @@ def start_test(self):


class TestQueueNameDeclareAndDelete(AsyncTestCase):

def begin(self, channel):
channel.queue_declare(self.on_queue_declared, str(id(self)),
passive=False,
Expand All @@ -159,11 +152,9 @@ def start_test(self):


class TestQueueRedeclareWithDifferentValues(AsyncTestCase):

def begin(self, channel):
self.channel.add_on_close_callback(self.on_channel_closed)
channel.queue_declare(self.on_queue_declared,
str(id(self)),
channel.queue_declare(self.on_queue_declared, str(id(self)),
passive=False,
durable=False,
exclusive=True,
Expand All @@ -175,8 +166,7 @@ def on_channel_closed(self, channel, reply_code, reply_text):
self.stop()

def on_queue_declared(self, frame):
self.channel.queue_declare(self.on_bad_result,
str(id(self)),
self.channel.queue_declare(self.on_bad_result, str(id(self)),
passive=False,
durable=True,
exclusive=False,
Expand All @@ -196,7 +186,6 @@ def start_test(self):


class TestTX1_Select(AsyncTestCase):

def begin(self, channel):
channel.tx_select(self.on_complete)

Expand All @@ -210,7 +199,6 @@ def test_confirm_select(self):


class TestTX2_Commit(AsyncTestCase):

def begin(self, channel):
channel.tx_select(self.on_selectok)

Expand All @@ -228,7 +216,6 @@ def start_test(self):


class TestTX2_CommitFailure(AsyncTestCase):

def begin(self, channel):
self.channel.add_on_close_callback(self.on_channel_closed)
self.channel.tx_commit(self.on_commitok)
Expand All @@ -248,7 +235,6 @@ def start_test(self):


class TestTX3_Rollback(AsyncTestCase):

def begin(self, channel):
channel.tx_select(self.on_selectok)

Expand All @@ -266,7 +252,6 @@ def start_test(self):


class TestTX3_RollbackFailure(AsyncTestCase):

def begin(self, channel):
self.channel.add_on_close_callback(self.on_channel_closed)
self.channel.tx_rollback(self.on_commitok)
Expand All @@ -283,12 +268,10 @@ def start_test(self):


class TestZ_PublishAndConsume(BoundQueueTestCase):

def on_ready(self, frame):
self.ctag = self.channel.basic_consume(self.on_message, self.queue)
self.msg_body = "%s: %i" % (self.__class__.__name__, time.time())
self.channel.basic_publish(self.exchange,
self.routing_key,
self.channel.basic_publish(self.exchange, self.routing_key,
self.msg_body)

def on_cancelled(self, frame):
Expand All @@ -307,15 +290,13 @@ def start_test(self):


class TestZ_PublishAndConsumeBig(BoundQueueTestCase):

def _get_msg_body(self):
return '\n'.join(["%s" % i for i in range(0, 2097152)])

def on_ready(self, frame):
self.ctag = self.channel.basic_consume(self.on_message, self.queue)
self.msg_body = self._get_msg_body()
self.channel.basic_publish(self.exchange,
self.routing_key,
self.channel.basic_publish(self.exchange, self.routing_key,
self.msg_body)

def on_cancelled(self, frame):
Expand All @@ -333,13 +314,10 @@ def start_test(self):
self.start()



class TestZ_PublishAndGet(BoundQueueTestCase):

def on_ready(self, frame):
self.msg_body = "%s: %i" % (self.__class__.__name__, time.time())
self.channel.basic_publish(self.exchange,
self.routing_key,
self.channel.basic_publish(self.exchange, self.routing_key,
self.msg_body)
self.channel.basic_get(self.on_get, self.queue)

Expand All @@ -352,4 +330,3 @@ def on_get(self, channel, method, header, body):
def start_test(self):
"""AsyncoreConnection should publish a message and get it"""
self.start()

0 comments on commit 4528a1a

Please sign in to comment.