Exemplo n.º 1
0
 def test_decrease_poolsize(self):
     # Test increasing and decreasing the pool size
     max_connections = 3
     protocol = Protocol(config=Configuration(
         service_endpoint='https://example.com/Foo.asmx',
         credentials=Credentials(get_random_string(8), get_random_string(
             8)),
         auth_type=NTLM,
         version=Version(Build(15, 1)),
         retry_policy=FailFast(),
         max_connections=max_connections,
     ))
     self.assertEqual(protocol._session_pool.qsize(), 0)
     self.assertEqual(protocol.session_pool_size, 0)
     protocol.increase_poolsize()
     protocol.increase_poolsize()
     protocol.increase_poolsize()
     with self.assertRaises(SessionPoolMaxSizeReached):
         protocol.increase_poolsize()
     self.assertEqual(protocol._session_pool.qsize(), max_connections)
     self.assertEqual(protocol.session_pool_size, max_connections)
     protocol.decrease_poolsize()
     protocol.decrease_poolsize()
     with self.assertRaises(SessionPoolMinSizeReached):
         protocol.decrease_poolsize()
     self.assertEqual(protocol._session_pool.qsize(), 1)
Exemplo n.º 2
0
 def test_decrease_poolsize(self):
     protocol = Protocol(config=Configuration(
         service_endpoint='https://example.com/Foo.asmx', credentials=Credentials('A', 'B'),
         auth_type=NTLM, version=Version(Build(15, 1)), retry_policy=FailFast()
     ))
     self.assertEqual(protocol._session_pool.qsize(), Protocol.SESSION_POOLSIZE)
     protocol.decrease_poolsize()
     self.assertEqual(protocol._session_pool.qsize(), 3)
     protocol.decrease_poolsize()
     self.assertEqual(protocol._session_pool.qsize(), 2)
     protocol.decrease_poolsize()
     self.assertEqual(protocol._session_pool.qsize(), 1)
     with self.assertRaises(SessionPoolMinSizeReached):
         protocol.decrease_poolsize()
     self.assertEqual(protocol._session_pool.qsize(), 1)