summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHuanhuan Li <huanhuanx.li@intel.com>2013-08-23 07:11:09 +0800
committerHuanhuanX Li <huanhuanx.li@intel.com>2014-03-05 10:27:05 +0200
commit5240d9239351b1a5ec71676e9c652927f1cd9532 (patch)
treee7a472bbe723fa109e77b68c74e32989200c4ca3 /tests
parent1b719123a0abaac4adcfb879ebd04c12de1266c1 (diff)
downloadmic-5240d9239351b1a5ec71676e9c652927f1cd9532.tar.gz
mic-5240d9239351b1a5ec71676e9c652927f1cd9532.tar.bz2
mic-5240d9239351b1a5ec71676e9c652927f1cd9532.zip
Add unit test for proxy
Change-Id: Ic3f5567df03125ef28ca96e16b23869996a6d6ed
Diffstat (limited to 'tests')
-rw-r--r--tests/suite.py2
-rw-r--r--tests/test_proxy.py34
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/suite.py b/tests/suite.py
index 66abd2d..dea87ab 100644
--- a/tests/suite.py
+++ b/tests/suite.py
@@ -7,6 +7,7 @@ import test_baseimager
#import test_msger
import test_runner
import test_chroot
+import test_proxy
if os.getuid() != 0:
raise SystemExit("Root permission is needed")
@@ -18,5 +19,6 @@ suite.addTests(test_baseimager.suite())
#suite.addTests(test_msger.suite())
suite.addTests(test_runner.suite())
suite.addTests(test_chroot.suite())
+suite.addTests(test_proxy.suite())
result = unittest.TextTestRunner(verbosity=2).run(suite)
sys.exit(not result.wasSuccessful())
diff --git a/tests/test_proxy.py b/tests/test_proxy.py
new file mode 100644
index 0000000..9655b58
--- /dev/null
+++ b/tests/test_proxy.py
@@ -0,0 +1,34 @@
+#!/usr/bin/python
+
+import unittest
+from mic.utils import proxy
+
+def suite():
+ return unittest.makeSuite(ProxyTest)
+
+class ProxyTest(unittest.TestCase):
+
+ def test_proxy(self):
+ proxy.set_proxies('http://proxy.some.com:11', '1.2.3.4')
+ self.assertEqual(proxy.get_proxy_for('http://1.2.3.4'), None)
+ self.assertEqual(proxy.get_proxy_for('http://download.tizen.org'), 'http://proxy.some.com:11')
+
+ proxy.set_proxies('http://proxy.some.com:11', 'download.am.org')
+ self.assertEqual(proxy.get_proxy_for('http://download.am.org'), None)
+ self.assertEqual(proxy.get_proxy_for('https://download.am.org'), None)
+ self.assertEqual(proxy.get_proxy_for('http://download.tizen.org'), 'http://proxy.some.com:11')
+
+ proxy.set_proxies('http://proxy.some.com:11', '1.2.3.0/24')
+ self.assertEqual(proxy.get_proxy_for('http://1.2.3.4'), None)
+ self.assertEqual(proxy.get_proxy_for('http://1.2.3.0'), None)
+ self.assertEqual(proxy.get_proxy_for('http://1.2.3.255'), None)
+ self.assertEqual(proxy.get_proxy_for('http://download.tizen.org'), 'http://proxy.some.com:11')
+
+ proxy.set_proxies('http://proxy.some.com:11', '.hello.com')
+ self.assertEqual(proxy.get_proxy_for('http://linux.hello.com'), None)
+ self.assertEqual(proxy.get_proxy_for('http://linux.hello.com.org'), 'http://proxy.some.com:11')
+
+
+
+if __name__ == "__main__":
+ unittest.main()