Skip to content

Commit

Permalink
Test ConnectionMultiplexer set and deleting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Renelvon committed Jun 5, 2015
1 parent 506d359 commit 95b81b1
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion tests/test_rudp.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,25 @@ def test_set_and_get_new_connection(self):
self.assertIs(cm[self.addr], mock_connection)

def test_set_existent_connection(self):
pass
cm = self._make_cm_with_mocks()
mock_connection1 = mock.Mock(spec_set=connection.RUDPConnection)
mock_connection2 = mock.Mock(spec_set=connection.RUDPConnection)
cm[self.addr] = mock_connection1
cm[self.addr] = mock_connection2
self.assertIn(self.addr, cm)
self.assertIs(cm[self.addr], mock_connection2)
mock_connection1.shutdown.assert_called_once_with()
mock_connection2.shutdown.assert_not_called()

def test_del_nonexistent_connection(self):
cm = self._make_cm_with_mocks()
self.assertNotIn(self.addr, cm)
with self.assertRaises(KeyError):
del cm[self.addr]

def test_del_existent_connection(self):
cm = self._make_cm_with_mocks()
mock_connection = mock.Mock(spec_set=connection.RUDPConnection)
cm[self.addr] = mock_connection
del cm[self.addr]
self.assertNotIn(self.addr, cm)

0 comments on commit 95b81b1

Please sign in to comment.