Beispiel #1
0
    def test_without_host(self):
        # Given
        s = ""

        # When/Then
        with self.assertRaises(InvalidConfiguration):
            ProxyInfo.from_string(s)

        # Given
        s = ":3128"

        # When/Then
        with self.assertRaises(InvalidConfiguration):
            ProxyInfo.from_string(s)
Beispiel #2
0
    def test_without_host(self):
        # Given
        s = ""

        # When/Then
        with self.assertRaises(InvalidConfiguration):
            ProxyInfo.from_string(s)

        # Given
        s = ":3128"

        # When/Then
        with self.assertRaises(InvalidConfiguration):
            ProxyInfo.from_string(s)
Beispiel #3
0
    def test_str_full(self):
        # Given
        proxy_info = ProxyInfo.from_string("http://*****:*****@acme.com:3129")

        # When
        s = str(proxy_info)

        # Then
        self.assertEqual(s, "http://*****:*****@acme.com:3129")
Beispiel #4
0
    def test_str_full(self):
        # Given
        proxy_info = ProxyInfo.from_string("http://*****:*****@acme.com:3129")

        # When
        s = str(proxy_info)

        # Then
        self.assertEqual(s, "http://*****:*****@acme.com:3129")
Beispiel #5
0
    def test_scheme(self):
        # Given
        s = "https://[email protected]"

        # When
        info = ProxyInfo.from_string(s)

        # Then
        self.assertEqual(info.scheme, "https")
        self.assertEqual(info.user, "john")
        self.assertEqual(info.password, "")
        self.assertEqual(info.port, 3128)
Beispiel #6
0
    def test_simple_user(self):
        # Given
        s = "http://*****:*****@acme.com"

        # When
        info = ProxyInfo.from_string(s)

        # Then
        self.assertEqual(info.scheme, "http")
        self.assertEqual(info.user, "john")
        self.assertEqual(info.password, "doe")
        self.assertEqual(info.port, 3128)
Beispiel #7
0
    def test_simple_port(self):
        # Given
        s = "http://acme.com:3129"

        # When
        info = ProxyInfo.from_string(s)

        # Then
        self.assertEqual(info.scheme, "http")
        self.assertEqual(info.user, "")
        self.assertEqual(info.password, "")
        self.assertEqual(info.port, 3129)
Beispiel #8
0
    def test_scheme(self):
        # Given
        s = "https://[email protected]"

        # When
        info = ProxyInfo.from_string(s)

        # Then
        self.assertEqual(info.scheme, "https")
        self.assertEqual(info.user, "john")
        self.assertEqual(info.password, "")
        self.assertEqual(info.port, 3128)
Beispiel #9
0
    def test_simple_user(self):
        # Given
        s = "http://*****:*****@acme.com"

        # When
        info = ProxyInfo.from_string(s)

        # Then
        self.assertEqual(info.scheme, "http")
        self.assertEqual(info.user, "john")
        self.assertEqual(info.password, "doe")
        self.assertEqual(info.port, 3128)
Beispiel #10
0
    def test_simple_port(self):
        # Given
        s = "http://acme.com:3129"

        # When
        info = ProxyInfo.from_string(s)

        # Then
        self.assertEqual(info.scheme, "http")
        self.assertEqual(info.user, "")
        self.assertEqual(info.password, "")
        self.assertEqual(info.port, 3129)
Beispiel #11
0
    def test_without_scheme(self):
        # Given
        s = "acme.com:3129"

        # When
        info = ProxyInfo.from_string(s)

        # Then
        self.assertEqual(info.scheme, "http")
        self.assertEqual(info.host, "acme.com")
        self.assertEqual(info.user, "")
        self.assertEqual(info.password, "")
        self.assertEqual(info.port, 3129)
Beispiel #12
0
    def test_without_scheme(self):
        # Given
        s = "acme.com:3129"

        # When
        info = ProxyInfo.from_string(s)

        # Then
        self.assertEqual(info.scheme, "http")
        self.assertEqual(info.host, "acme.com")
        self.assertEqual(info.user, "")
        self.assertEqual(info.password, "")
        self.assertEqual(info.port, 3129)
Beispiel #13
0
 def _set_proxy(self, proxy_string):
     self._proxy = ProxyInfo.from_string(proxy_string)
Beispiel #14
0
 def _set_proxy(self, proxy_string):
     self._proxy = ProxyInfo.from_string(proxy_string)
Beispiel #15
0
 def test_no_user(self):
     with self.assertRaises(InvalidConfiguration):
         ProxyInfo("acme.com", password="******")