コード例 #1
0
    def test_proxy_port_conversion(self):
        proxy_port = "8888"
        proxy_options = ProxyOptions(
            proxy_type=socks.HTTP, proxy_addr="127.0.0.1", proxy_port=proxy_port
        )

        assert proxy_options.proxy_port == int(proxy_port)
コード例 #2
0
    def test_proxy_type(self, proxy_type_input, expected_proxy_type, expected_proxy_type_socks):
        proxy_options = ProxyOptions(
            proxy_type=proxy_type_input, proxy_addr="127.0.0.1", proxy_port=8888
        )

        assert proxy_options.proxy_type == expected_proxy_type
        assert proxy_options.proxy_type_socks == expected_proxy_type_socks
コード例 #3
0
    def test_proxy_port(self):
        proxy_port = 8888
        proxy_options = ProxyOptions(
            proxy_type=socks.HTTP, proxy_addr="127.0.0.1", proxy_port=proxy_port
        )

        assert proxy_options.proxy_port == proxy_port
コード例 #4
0
    def test_proxy_port(self, mocker):
        proxy_port = 8888
        proxy_options = ProxyOptions(proxy_type=mocker.MagicMock(),
                                     proxy_addr="127.0.0.1",
                                     proxy_port=proxy_port)

        assert proxy_options.proxy_port == proxy_port
コード例 #5
0
    def test_proxy_password(self):
        proxy_password = "******"
        proxy_options = ProxyOptions(
            proxy_type=socks.HTTP,
            proxy_addr="127.0.0.1",
            proxy_port=8888,
            proxy_password=proxy_password,
        )

        assert proxy_options.proxy_password == proxy_password
コード例 #6
0
    def test_proxy_username(self):
        proxy_username = "******"
        proxy_options = ProxyOptions(
            proxy_type=socks.HTTP,
            proxy_addr="127.0.0.1",
            proxy_port=8888,
            proxy_username=proxy_username,
        )

        assert proxy_options.proxy_username == proxy_username
コード例 #7
0
    def test_proxy_username(self, mocker):
        proxy_username = "******"
        proxy_options = ProxyOptions(
            proxy_type=mocker.MagicMock(),
            proxy_addr="127.0.0.1",
            proxy_port=8888,
            proxy_username=proxy_username,
        )

        assert proxy_options.proxy_username == proxy_username
コード例 #8
0
    def test_proxy_password(self, mocker):
        proxy_password = "******"
        proxy_options = ProxyOptions(
            proxy_type=mocker.MagicMock(),
            proxy_addr="127.0.0.1",
            proxy_port=8888,
            proxy_password=proxy_password,
        )

        assert proxy_options.proxy_password == proxy_password
コード例 #9
0
    def proxy_options(self, request):
        if "HTTP" in request.param:
            proxy_type = "HTTP"
        elif "SOCKS4" in request.param:
            proxy_type = "SOCKS4"
        else:
            proxy_type = "SOCKS5"

        if "No Auth" in request.param:
            proxy = ProxyOptions(proxy_type=proxy_type,
                                 proxy_addr="127.0.0.1",
                                 proxy_port=1080)
        else:
            proxy = ProxyOptions(
                proxy_type=proxy_type,
                proxy_addr="127.0.0.1",
                proxy_port=1080,
                proxy_username="******",
                proxy_password="******",
            )
        return proxy
コード例 #10
0
 def test_proxy_port_read_only(self):
     proxy_options = ProxyOptions(proxy_type=socks.HTTP, proxy_addr="127.0.0.1", proxy_port=8888)
     with pytest.raises(AttributeError):
         proxy_options.proxy_port = "new value"
コード例 #11
0
    def test_proxy_address(self):
        proxy_addr = "127.0.0.1"
        proxy_options = ProxyOptions(proxy_type=socks.HTTP, proxy_addr=proxy_addr, proxy_port=8888)

        assert proxy_options.proxy_address == proxy_addr
コード例 #12
0
 def test_invalid_proxy_type(self):
     with pytest.raises(ValueError):
         ProxyOptions(proxy_type="INVALID", proxy_addr="127.0.0.1", proxy_port=8888)
コード例 #13
0
 def test_proxy_password_default(self):
     proxy_options = ProxyOptions(proxy_type=socks.HTTP, proxy_addr="127.0.0.1", proxy_port=8888)
     assert proxy_options.proxy_password is None
コード例 #14
0
 def test_proxy_username_read_only(self, mocker):
     proxy_options = ProxyOptions(proxy_type=mocker.MagicMock(),
                                  proxy_addr="127.0.0.1",
                                  proxy_port=8888)
     with pytest.raises(AttributeError):
         proxy_options.proxy_username = "******"
コード例 #15
0
 def test_proxy_username_default(self, mocker):
     proxy_options = ProxyOptions(proxy_type=mocker.MagicMock(),
                                  proxy_addr="127.0.0.1",
                                  proxy_port=8888)
     assert proxy_options.proxy_username is None