コード例 #1
0
    def test_construct_with_proxy_without_authentication(self):
        """Tests construction of a DefaultConnection with an unauthenticated proxy"""
        proxy_config = ProxyConfiguration.from_uri("http://test-proxy")

        connection = DefaultConnection(CONNECT_TIMEOUT,
                                       SOCKET_TIMEOUT,
                                       proxy_configuration=proxy_config)

        self.assertTimeouts(self, connection, CONNECT_TIMEOUT, SOCKET_TIMEOUT)
        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            self.assertMaxConnections(
                self, connection,
                CommunicatorConfiguration.DEFAULT_MAX_CONNECTIONS,
                proxy_config)
            self.assertProxy(self, connection, proxy_config)
コード例 #2
0
    def test_construct_with_max_connections_with_proxy(self):
        """Tests construction of a DefaultConnection
        with a different amount of max connections and an unauthenticated proxy
        """
        proxy_config = ProxyConfiguration.from_uri("http://test-proxy")

        connection = DefaultConnection(CONNECT_TIMEOUT,
                                       SOCKET_TIMEOUT,
                                       MAX_CONNECTIONS,
                                       proxy_configuration=proxy_config)

        self.assertTimeouts(self, connection, CONNECT_TIMEOUT, SOCKET_TIMEOUT)
        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            self.assertMaxConnections(self, connection, MAX_CONNECTIONS,
                                      proxy_config)
            self.assertProxy(self, connection, proxy_config)
コード例 #3
0
 def test_connect_nonexistent_proxy(self):
     """Try connecting to a nonexistent proxy and assert it fails to connect to it"""
     configparser = ConfigParser.ConfigParser()
     configparser.read(init_utils.PROPERTIES_URL_PROXY)
     communicator_config = CommunicatorConfiguration(
         configparser,
         connect_timeout=1,
         socket_timeout=1,
         api_key_id=init_utils.API_KEY_ID,
         secret_api_key=init_utils.SECRET_API_KEY,
         proxy_configuration=ProxyConfiguration(host="localhost",
                                                port=65535,
                                                username="******",
                                                password="******"))
     with Factory.create_client_from_configuration(
             communicator_config) as client:
         with self.assertRaises(CommunicationException):
             client.merchant(MERCHANT_ID).services().testconnection()