Skip to content

Commit

Permalink
Merge branch 'feature/issue-1033-always-wrap-abort-connection' into d…
Browse files Browse the repository at this point in the history
…evelop
  • Loading branch information
hodgestar committed Apr 8, 2016
2 parents 4434372 + 605a897 commit 9964228
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions vumi/tests/fake_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,21 @@ def patch_transport_fake_push_producer(transport):

def patch_transport_abortConnection(transport, protocol):
"""
Patch abortConnection() onto the transport if it doesn't already have it.
(`Agent` assumes its transport has this.)
Patch abortConnection() on the transport or add it if it doesn't already
exist (`Agent` assumes its transport has this).
The patched method sets an internal flag recording the abort and then calls
the original method (if it existed) or transport.loseConnection (if it
didn't).
"""
_old_abortConnection = getattr(
transport, 'abortConnection', transport.loseConnection)

def abortConnection():
protocol._fake_connection_aborted = True
transport.loseConnection()
patch_if_missing(transport, 'abortConnection', abortConnection)
_old_abortConnection()

transport.abortConnection = abortConnection


class FakeServerProtocolWrapper(Protocol):
Expand Down

0 comments on commit 9964228

Please sign in to comment.