libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [2/2] git commit: Add tests for is_public_subnet and is_private_subnet function.
Date Wed, 04 Dec 2013 01:20:53 GMT
Add tests for is_public_subnet and is_private_subnet function.


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/146a4890
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/146a4890
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/146a4890

Branch: refs/heads/trunk
Commit: 146a4890ea65a590e5273e62db8346beb6f97e70
Parents: fad678a
Author: Tomaz Muraus <tomaz@apache.org>
Authored: Wed Dec 4 01:40:52 2013 +0100
Committer: Tomaz Muraus <tomaz@apache.org>
Committed: Wed Dec 4 01:40:52 2013 +0100

----------------------------------------------------------------------
 libcloud/test/test_utils.py | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/146a4890/libcloud/test/test_utils.py
----------------------------------------------------------------------
diff --git a/libcloud/test/test_utils.py b/libcloud/test/test_utils.py
index 9e147b6..cd8950b 100644
--- a/libcloud/test/test_utils.py
+++ b/libcloud/test/test_utils.py
@@ -37,6 +37,8 @@ from libcloud.utils.py3 import urlquote
 from libcloud.compute.types import Provider
 from libcloud.compute.providers import DRIVERS
 from libcloud.utils.misc import get_secure_random_string
+from libcloud.utils.networking import is_public_subnet
+from libcloud.utils.networking import is_private_subnet
 from libcloud.utils.networking import is_valid_ip_address
 
 
@@ -238,6 +240,34 @@ class TestUtils(unittest.TestCase):
 
 
 class NetworkingUtilsTestCase(unittest.TestCase):
+    def test_is_public_and_is_private_subnet(self):
+        public_ips = [
+            '213.151.0.8',
+            '86.87.86.1',
+            '8.8.8.8',
+            '8.8.4.4'
+        ]
+
+        private_ips = [
+            '192.168.1.100',
+            '10.0.0.1',
+            '172.16.0.0'
+        ]
+
+        for address in public_ips:
+            is_public = is_public_subnet(ip=address)
+            is_private = is_private_subnet(ip=address)
+
+            self.assertTrue(is_public)
+            self.assertFalse(is_private)
+
+        for address in private_ips:
+            is_public = is_public_subnet(ip=address)
+            is_private = is_private_subnet(ip=address)
+
+            self.assertFalse(is_public)
+            self.assertTrue(is_private)
+
     def test_is_valid_ip_address(self):
         valid_ipv4_addresses = [
             '192.168.1.100',


Mime
View raw message