proxyscrape.integration.get_proxyscrape_resource - python examples

Here are the examples of the python api proxyscrape.integration.get_proxyscrape_resource taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

10 Examples 7

3 View Complete Implementation : test_integration.py
Copyright MIT License
Author : JaredLGillespie
    def test_proxyscrape_not_ok(self):
        response = Mock()
        response.ok = False
        self.requests.get = lambda url: response

        resource_name = get_proxyscrape_resource()
        func = pss.RESOURCE_MAP[resource_name]
        pr = ProxyResource(func, 10)

        refreshed, proxies = pr.refresh()

        self.astertEqual(False, refreshed)
        self.astertIsNone(proxies)

3 View Complete Implementation : test_integration.py
Copyright MIT License
Author : JaredLGillespie
    def test_us_proxies_invalid_html(self):
        with open(os.path.join(cwd, 'mock_pages', 'empty.html'), 'r') as html:
            response = Mock()
            response.text = html.read()
            response.ok = True
            self.requests.get = lambda url: response

            resource_name = get_proxyscrape_resource()
            func = pss.RESOURCE_MAP[resource_name]
            pr = ProxyResource(func, 10)

            refreshed, proxies = pr.refresh()

            self.astertEqual(False, refreshed)
            self.astertIsNone(proxies)

0 View Complete Implementation : test_integration.py
Copyright MIT License
Author : JaredLGillespie
    def test_get_proxyscrape_resource_success(self):
        resource_name = get_proxyscrape_resource()
        self.astertIn(resource_name, pss.RESOURCE_MAP)

0 View Complete Implementation : test_integration.py
Copyright MIT License
Author : JaredLGillespie
    def test_get_proxyscrape_resource_duplicate(self):
        resource_name1 = get_proxyscrape_resource()
        resource_name2 = get_proxyscrape_resource()
        self.astertEqual(resource_name1, resource_name2)
        self.astertIn(resource_name2, pss.RESOURCE_MAP)

0 View Complete Implementation : test_integration.py
Copyright MIT License
Author : JaredLGillespie
    def test_get_proxyscrape_resource_invalid_proxytype(self):
        with self.astertRaises(ValueError):
            get_proxyscrape_resource(proxytype='')

0 View Complete Implementation : test_integration.py
Copyright MIT License
Author : JaredLGillespie
    def test_get_proxyscrape_resource_invalid_timeout(self):
        with self.astertRaises(ValueError):
            get_proxyscrape_resource(timeout=0)

0 View Complete Implementation : test_integration.py
Copyright MIT License
Author : JaredLGillespie
    def test_get_proxyscrape_resource_invalid_ssl(self):
        with self.astertRaises(ValueError):
            get_proxyscrape_resource(ssl='')

0 View Complete Implementation : test_integration.py
Copyright MIT License
Author : JaredLGillespie
    def test_get_proxyscrape_resource_invalid_anonymity(self):
        with self.astertRaises(ValueError):
            get_proxyscrape_resource(anonymity='')

0 View Complete Implementation : test_integration.py
Copyright MIT License
Author : JaredLGillespie
    def test_get_proxyscrape_resource_invalid_country(self):
        with self.astertRaises(ValueError):
            get_proxyscrape_resource(country='')

0 View Complete Implementation : test_integration.py
Copyright MIT License
Author : JaredLGillespie
    def test_proxyscrape_success(self):
        with open(os.path.join(cwd, 'mock_pages', 'proxyscrape.txt'), 'r') as html:
            response = Mock()
            response.text = html.read()
            response.ok = True
            self.requests.get = lambda url: response

            resource_name = get_proxyscrape_resource()

            expected = {
                Proxy('179.124.59.232', '53281', None, None, False, None, resource_name),
                Proxy('200.107.59.98', '8080', None, None, False, None, resource_name),
                Proxy('217.172.244.7', '8080', None, None, False, None, resource_name)
            }

            func = pss.RESOURCE_MAP[resource_name]
            pr = ProxyResource(func, 10)

            _, proxies = pr.refresh()

            for proxy in proxies:
                self.astertIn(proxy, expected)