Merge lp://staging/~free.ekanayaka/txamqp/synchronous-testing-helpers into lp://staging/txamqp

Proposed by Free Ekanayaka
Status: Merged
Merge reported by: Esteve Fernandez
Merged at revision: not available
Proposed branch: lp://staging/~free.ekanayaka/txamqp/synchronous-testing-helpers
Merge into: lp://staging/txamqp
Diff against target: 355 lines (+270/-12)
6 files modified
src/txamqp/factory.py (+3/-8)
src/txamqp/protocol.py (+4/-3)
src/txamqp/spec.py (+6/-1)
src/txamqp/test/test_factory.py (+8/-0)
src/txamqp/test/test_testing.py (+52/-0)
src/txamqp/testing.py (+197/-0)
To merge this branch: bzr merge lp://staging/~free.ekanayaka/txamqp/synchronous-testing-helpers
Reviewer Review Type Date Requested Status
Esteve Fernandez Approve
Review via email: mp+296293@code.staging.launchpad.net

Description of the change

This adds a new txamqp.testing.AMQPump class which can use as a fake AMQP transport for writing synchronous unit tests in a convenient way. Example:

client = AMQClient(...)
transport = AMQPump()
transport.connect(client)
channel = self.successResultOf(client.channel(1))
d = clientChannel.basic_consume(queue="test-queue")
transport.channel(1).basic_consume_ok(consumer_tag="consumer")
self.assertTrue(self.successResultOf(d))

The branch also fixes a small bug in txamqp.factory.AMQFactory where newly built protocols were not passed a fresh TwistedDelegate.

It also moves the DEFAULT_SPEC constant from txamqp.factory to txamqp.spec
which seems a better fit.

Finally it makes AMQClient pass its clock to callLater, for easier synchronous testing.

To post a comment you must log in.
Revision history for this message
Esteve Fernandez (esteve) wrote :

Sorry, I seem to have missed this one. Looks great, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to status/vote changes: