def test_invalid(self): with self.assertRaises(BadOption): DirectSplashProxyFactory('This is not a valid URL') with self.assertRaises(BadOption): DirectSplashProxyFactory('ftp://proxy.com') with self.assertRaises(BadOption): DirectSplashProxyFactory('relative_url')
def test_parse(self): factory = DirectSplashProxyFactory('http://*****:*****@proxy.com:1234') self.assertEqual(factory.proxy.port(), 1234) self.assertEqual(factory.proxy.user(), 'pepe') self.assertEqual(factory.proxy.password(), 'hunter2') self.assertEqual(factory.proxy.hostName(), 'proxy.com') self.assertEqual(factory.proxy.type(), PROXY_TYPES['HTTP'])
def test_socks5(self): factory = DirectSplashProxyFactory('socks5://proxy.com') self.assertEquals(factory.proxy.type(), PROXY_TYPES['SOCKS5'])
def test_default_port(self): factory = DirectSplashProxyFactory('http://proxy.com') self.assertEquals(factory.proxy.port(), 1080)