示例#1
0
def read_proxy_file(file_path):
    """
        Method used by the create_proxy method. Reads the file at the given file path and uses the CSVReader and
        ProxyExtractor classes from the Parsing module to convert the contents of the file to usable Proxy objects.

        :param file_path: Path to the proxy file
        :return: List with extracted Proxies. List will be empty if no proxies where found.
    """
    reader = CSVReader(file_path)
    extractor = ProxyExtractor(reader)
    proxy_list = extractor.get_all_proxies()
    return proxy_list
示例#2
0
def read_proxy_file(file_path):
    """
        Method used by the create_proxy method. Reads the file at the given file path and uses the CSVReader and
        ProxyExtractor classes from the Parsing module to convert the contents of the file to usable Proxy objects.

        :param file_path: Path to the proxy file
        :return: List with extracted Proxies. List will be empty if no proxies where found.
    """
    reader = CSVReader(file_path)
    extractor = ProxyExtractor(reader)
    proxy_list = extractor.get_all_proxies()
    return proxy_list
class TestProxyExtractor(TestCase):
    def setUp(self):
        proxy_file_path = './Docs/Proxyfile_examples/local_proxy.csv'
        reader = CSVReader(proxy_file_path)
        self._extractor = ProxyExtractor(reader)

    def test_get_proxy(self):
        self.assertIsInstance(self._extractor.get_proxy(0), HttpProxy)

    def test_get_all_proxies(self):
        self.assertIsInstance(self._extractor.get_all_proxies()[0], HttpProxy)

    def test_get_count(self):
        self.assertEqual(self._extractor.get_proxy_count(), 1)

    def test_index_error(self):
        with self.assertRaises(IndexError):
            self._extractor.get_proxy(100)

    def tearDown(self):
        pass
class TestProxyExtractor(TestCase):

    def setUp(self):
        proxy_file_path = './Docs/Proxyfile_examples/local_proxy.csv'
        reader = CSVReader(proxy_file_path)
        self._extractor = ProxyExtractor(reader)

    def test_get_proxy(self):
        self.assertIsInstance(self._extractor.get_proxy(0), HttpProxy)

    def test_get_all_proxies(self):
        self.assertIsInstance(self._extractor.get_all_proxies()[0], HttpProxy)

    def test_get_count(self):
        self.assertEqual(self._extractor.get_proxy_count(), 1)

    def test_index_error(self):
        with self.assertRaises(IndexError):
            self._extractor.get_proxy(100)

    def tearDown(self):
        pass
 def setUp(self):
     proxy_file_path = './Docs/Proxyfile_examples/local_proxy.csv'
     reader = CSVReader(proxy_file_path)
     self._extractor = ProxyExtractor(reader)
 def setUp(self):
     proxy_file_path = './Docs/Proxyfile_examples/local_proxy.csv'
     reader = CSVReader(proxy_file_path)
     self._extractor = ProxyExtractor(reader)