tests: Test reconnect delay calculation.

This commit is contained in:
Shiz 2014-03-15 00:48:57 +01:00
parent b8c18ec8fa
commit 9b4ab3fd13
1 changed files with 14 additions and 0 deletions

View File

@ -35,6 +35,20 @@ def test_client_reconnect_delay(server, client):
time.sleep(1.1) time.sleep(1.1)
assert client.connected assert client.connected
@with_client()
def test_client_reconnect_delay_calculation(server, client):
client.RECONNECT_DELAYED = False
assert client._reconnect_delay() == 0
client.RECONNECT_DELAYED = True
for expected_delay in client.RECONNECT_DELAYS:
delay = client._reconnect_delay()
assert delay == expected_delay
client._reconnect_attempts += 1
assert client._reconnect_delay() == client.RECONNECT_DELAYS[-1]
@with_client() @with_client()
def test_client_disconnect_on_connect(server, client): def test_client_disconnect_on_connect(server, client):
client.disconnect = Mock() client.disconnect = Mock()