示例#1
0
 def test_max_retries_config_error(self, new_retry_policy):
     config = {
         "example.endpoint": "127.0.0.1:1234",
         "example.max_retries": "5",
     }
     with self.assertRaises(Exception):
         thrift_pool.thrift_pool_from_config(config, prefix="example.")
 def test_max_connection_attempts_works_through_config(
         self, new_retry_policy):
     config = {
         "example.endpoint": "127.0.0.1:1234",
         "example.max_connection_attempts": "5"
     }
     thrift_pool.thrift_pool_from_config(config, prefix="example.")
     new_retry_policy.assert_called_with(attempts=5)
 def test_max_retries_still_works_through_config(self, new_retry_policy):
     config = {
         "example.endpoint": "127.0.0.1:1234",
         "example.max_retries": "5"
     }
     with pytest.deprecated_call():
         thrift_pool.thrift_pool_from_config(config, prefix="example.")
     new_retry_policy.assert_called_with(attempts=5)
 def test_dont_configure_both(self, new_retry_policy):
     config = {
         "example.endpoint": "127.0.0.1:1234",
         "example.max_retries": "5",
         "example.max_connection_attempts": "5",
     }
     with self.assertRaises(Exception):
         thrift_pool.thrift_pool_from_config(config, prefix="example.")
示例#5
0
 def parse(self, key_path: str, raw_config: config.RawConfig) -> ContextFactory:
     pool = thrift_pool_from_config(raw_config, prefix=f"{key_path}.", **self.kwargs)
     return ThriftContextFactory(pool, self.client_cls)
 def test_default_through_parser(self, new_retry_policy):
     config = {"example.endpoint": "127.0.0.1:1234"}
     thrift_pool.thrift_pool_from_config(config, prefix="example.")
     new_retry_policy.assert_called_with(attempts=3)