aboutsummaryrefslogtreecommitdiffstats
path: root/os_net_config/tests/test_objects.py
diff options
context:
space:
mode:
authorDan Prince <dprince@redhat.com>2014-06-09 16:38:34 -0400
committerDan Prince <dprince@redhat.com>2014-06-09 16:38:34 -0400
commitaf110352f8f61f68c4758f2c8c0846f9691e6bf1 (patch)
tree80b11a4f75873f4b6eb4aaf2235c979357cf4d46 /os_net_config/tests/test_objects.py
parent846e00d0072533e817c3d2248834e3b3ac5cae98 (diff)
Initial ifcfg implementation for interfaces/routes
Ifcfg formatted persistence for interfaces and routes.
Diffstat (limited to 'os_net_config/tests/test_objects.py')
-rw-r--r--os_net_config/tests/test_objects.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/os_net_config/tests/test_objects.py b/os_net_config/tests/test_objects.py
new file mode 100644
index 0000000..7ffd5b3
--- /dev/null
+++ b/os_net_config/tests/test_objects.py
@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from os_net_config import objects
+from os_net_config.tests import base
+
+
+class TestAddress(base.TestCase):
+
+ def test_ipv4_address(self):
+ address = objects.Address('192.168.1.1/24')
+ self.assertEqual("192.168.1.1", address.ip)
+ self.assertEqual("255.255.255.0", address.netmask)
+ self.assertEqual(4, address.version)
+
+ def test_ipv6_address(self):
+ address = objects.Address('2001:abc:a::/64')
+ self.assertEqual("2001:abc:a::", address.ip)
+ self.assertEqual("ffff:ffff:ffff:ffff::", address.netmask)
+ self.assertEqual(6, address.version)
+
+
+class TestInterface(base.TestCase):
+
+ def test_interface_addresses(self):
+ v4_addr = objects.Address('192.168.1.1/24')
+ v6_addr = objects.Address('2001:abc:a::/64')
+ interface = objects.Interface('foo', addresses=[v4_addr, v6_addr])
+ self.assertEquals("192.168.1.1", interface.v4_addresses()[0].ip)
+ self.assertEquals("2001:abc:a::", interface.v6_addresses()[0].ip)