def test_constructor(self): proxy = AVProxy(proxy_file=Test.content[0][0]) assert proxy.get_proxy_url() == self.get_proxy_url(Test.content[0][1]) assert proxy.need_authentication() == False del proxy proxy = AVProxy(proxy_file=Test.content[1][0]) assert proxy.get_proxy_url() == self.get_proxy_url(Test.content[1][1]) assert proxy.need_authentication() == False del proxy proxy = AVProxy(proxy_file=Test.content[2][0]) assert proxy.get_proxy_url() == self.get_proxy_url(Test.content[2][1]) assert proxy.need_authentication() == True del proxy # Bad proxy file proxy = AVProxy(proxy_file=Test.content[3][0]) assert proxy.get_proxy_url() == None assert proxy.need_authentication() == False del proxy # Non-existent proxy file proxy = AVProxy(proxy_file="/tmp/as/sdadsa") assert proxy.get_proxy_url() == None assert proxy.need_authentication() == False del proxy
def test_constructor_5(self): """ AVProxy: Check non-existent proxy file """ self.mock_read_file.return_value = (False, 'not exist') proxy = AVProxy(proxy_file=self.fake_proxy_file) self.assertEqual(None, proxy.get_proxy_url()) self.assertFalse(proxy.need_authentication())
def test_constructor_3(self): """ AVProxy: Check auth proxy """ self.mock_read_file.return_value = (True, self.proxy_with_port_and_auth) proxy = AVProxy(proxy_file=self.fake_proxy_file) self.assertEqual(proxy.get_proxy_url(), self.get_proxy_url(self.proxy_with_port_and_auth)) self.assertTrue(proxy.need_authentication())
def test_constructor_4(self): """ AVProxy: Check bad proxy """ self.mock_read_file.return_value = (True, self.bad_proxy) proxy = AVProxy(proxy_file=self.fake_proxy_file) self.assertEqual(None, proxy.get_proxy_url()) self.assertFalse(proxy.need_authentication())
def test_constructor_5(self): """ AVProxy: Check non-existent proxy file """ self.mock_read_file.return_value = (False, 'not exist') proxy = AVProxy(proxy_file=self.fake_proxy_file) self.assertEqual(None, proxy.get_proxy_url()) self.assertFalse(proxy.need_authentication())
def test_constructor_4(self): """ AVProxy: Check bad proxy """ self.mock_read_file.return_value = (True, self.bad_proxy) proxy = AVProxy(proxy_file=self.fake_proxy_file) self.assertEqual(None, proxy.get_proxy_url()) self.assertFalse(proxy.need_authentication())
def test_constructor_1(self): """ AVProxy: No authentication required """ self.mock_read_file.return_value = (True, self.simple_proxy) proxy = AVProxy(proxy_file=self.fake_proxy_file) self.mock_read_file.assert_called_once_with('127.0.0.1', self.fake_proxy_file) self.assertEqual(proxy.get_proxy_url(), self.get_proxy_url(self.simple_proxy)) self.assertFalse(proxy.need_authentication())
def test_constructor_2(self): """ AVProxy: Check proxy with port """ self.mock_read_file.return_value = (True, self.proxy_with_port) proxy = AVProxy(proxy_file=self.fake_proxy_file) self.assertEqual(proxy.get_proxy_url(), self.get_proxy_url(self.proxy_with_port)) self.assertFalse(proxy.need_authentication())
def test_constructor_1(self): """ AVProxy: No authentication required """ self.mock_read_file.return_value = (True, self.simple_proxy) proxy = AVProxy(proxy_file=self.fake_proxy_file) self.mock_read_file.assert_called_once_with('127.0.0.1', self.fake_proxy_file) self.assertEqual(proxy.get_proxy_url(), self.get_proxy_url(self.simple_proxy)) self.assertFalse(proxy.need_authentication())