def test_least_connections_should_return_the_link_with_least_connections( self): link_1 = Link() link_2 = Link() link_3 = Link() link_1.open_connection("1") link_3.open_connection("1") links = [link_1, link_2, link_3] actual = least_connections.get_next_link(links) self.assertEqual(actual, link_2)
def test_open_and_close_connection_link(self): link = Link() self.assertEqual(len(link.connections), 0) socket_connection = link.open_connection("1") self.assertEqual(len(link.connections), 1) self.assertFalse(socket_connection._closed) self.assertIsInstance(socket_connection, socks.socksocket) link.close_connection("1") self.assertEqual(len(link.connections), 0) self.assertTrue(socket_connection._closed)