Skip to content

Commit

Permalink
No need to errback _connected_d when rejecting a connection.
Browse files Browse the repository at this point in the history
  • Loading branch information
jerith committed Sep 10, 2015
1 parent a3ca1e6 commit c5ccaf8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
7 changes: 3 additions & 4 deletions vumi/transports/smpp/tests/fake_smsc.py
Expand Up @@ -73,12 +73,11 @@ def reject_connection(self):
"""
Reject a pending connection.
This is only useful if auto-accept is disabled.
This is only useful if auto-accept is disabled. The deferred returned
by waiting for `await_connected()` for this connection will never fire.
"""
assert self.has_pending_connection(), "No pending connection."
err = ConnectionRefusedError()
self._accept_d.errback(err)
self._connected_d.errback(err)
self._accept_d.errback(ConnectionRefusedError())
self._reset_connection_ds()

def has_pending_connection(self):
Expand Down
9 changes: 3 additions & 6 deletions vumi/transports/smpp/tests/test_fake_smsc.py
Expand Up @@ -157,7 +157,7 @@ def test_reject_connection(self):
fake_smsc.reject_connection()
# The client is not connected.
self.failureResultOf(connect_d, ConnectionRefusedError)
self.failureResultOf(await_connected_d, ConnectionRefusedError)
self.assertNoResult(await_connected_d)
self.assertEqual(client.connected, False)

def test_reject_connection_no_pending(self):
Expand All @@ -176,20 +176,17 @@ def test_has_pending_connection(self):

# Pending connection we reject.
connect_d = self.connect(fake_smsc)
await_connected_d = fake_smsc.await_connected()
self.assertEqual(fake_smsc.has_pending_connection(), True)
fake_smsc.reject_connection()
self.assertEqual(fake_smsc.has_pending_connection(), False)
self.failureResultOf(connect_d)
self.failureResultOf(await_connected_d)

# Pending connection we accept.
self.connect(fake_smsc)
await_connected_d = fake_smsc.await_connected()
connected_d = self.connect(fake_smsc)
self.assertEqual(fake_smsc.has_pending_connection(), True)
fake_smsc.accept_connection()
self.assertEqual(fake_smsc.has_pending_connection(), False)
self.successResultOf(await_connected_d)
self.successResultOf(connected_d)

@inlineCallbacks
def test_send_bytes(self):
Expand Down

0 comments on commit c5ccaf8

Please sign in to comment.