Merge "Created domain class for routers."
[snaps.git] / snaps / domain / test / network_tests.py
index a2f1374..c394b4a 100644 (file)
 # limitations under the License.
 
 import unittest
-from snaps.domain.network import SecurityGroup, SecurityGroupRule
+from snaps.domain.network import (
+    Port, SecurityGroup, SecurityGroupRule,  Router, InterfaceRouter)
+
+
+class PortDomainObjectTests(unittest.TestCase):
+    """
+    Tests the construction of the snaps.domain.network.Port class
+    """
+
+    def test_construction_kwargs(self):
+        ips = ['10', '11']
+        port = Port(
+            **{'name': 'name', 'id': 'id', 'ips': ips})
+        self.assertEqual('name', port.name)
+        self.assertEqual('id', port.id)
+        self.assertEqual(ips, port.ips)
+
+    def test_construction_named(self):
+        ips = ['10', '11']
+        port = Port(ips=ips, id='id', name='name')
+        self.assertEqual('name', port.name)
+        self.assertEqual('id', port.id)
+        self.assertEqual(ips, port.ips)
+
+
+class RouterDomainObjectTests(unittest.TestCase):
+    """
+    Tests the construction of the snaps.domain.network.Router class
+    """
+
+    def test_construction_kwargs(self):
+        sec_grp = Router(
+            **{'name': 'name', 'id': 'id', 'status': 'hello',
+               'tenant_id': '1234', 'admin_state_up': 'yes',
+               'external_gateway_info': 'no'})
+        self.assertEqual('name', sec_grp.name)
+        self.assertEqual('id', sec_grp.id)
+        self.assertEqual('hello', sec_grp.status)
+        self.assertEqual('1234', sec_grp.tenant_id)
+        self.assertEqual('yes', sec_grp.admin_state_up)
+        self.assertEqual('no', sec_grp.external_gateway_info)
+
+    def test_construction_named(self):
+        sec_grp = Router(
+            external_gateway_info='no', admin_state_up='yes', tenant_id='1234',
+            status='hello', id='id', name='name')
+        self.assertEqual('name', sec_grp.name)
+        self.assertEqual('id', sec_grp.id)
+        self.assertEqual('hello', sec_grp.status)
+        self.assertEqual('1234', sec_grp.tenant_id)
+        self.assertEqual('yes', sec_grp.admin_state_up)
+        self.assertEqual('no', sec_grp.external_gateway_info)
+
+
+class InterfaceRouterDomainObjectTests(unittest.TestCase):
+    """
+    Tests the construction of the snaps.domain.network.InterfaceRouter class
+    """
+
+    def test_construction_kwargs(self):
+        sec_grp = InterfaceRouter(
+            **{'id': 'id', 'subnet_id': 'foo', 'port_id': 'bar'})
+        self.assertEqual('id', sec_grp.id)
+        self.assertEqual('foo', sec_grp.subnet_id)
+        self.assertEqual('bar', sec_grp.port_id)
+
+    def test_construction_named(self):
+        sec_grp = InterfaceRouter(port_id='bar', subnet_id='foo', id='id')
+        self.assertEqual('id', sec_grp.id)
+        self.assertEqual('foo', sec_grp.subnet_id)
+        self.assertEqual('bar', sec_grp.port_id)
 
 
 class SecurityGroupDomainObjectTests(unittest.TestCase):
     """
-    Tests the construction of the snaps.domain.test.SecurityGroup class
+    Tests the construction of the snaps.domain.network.SecurityGroup class
     """
 
     def test_construction_proj_id_kwargs(self):
@@ -47,13 +117,13 @@ class SecurityGroupDomainObjectTests(unittest.TestCase):
 
 class SecurityGroupRuleDomainObjectTests(unittest.TestCase):
     """
-    Tests the construction of the snaps.domain.test.SecurityGroupRule class
+    Tests the construction of the snaps.domain.network.SecurityGroupRule class
     """
 
     def test_construction_kwargs(self):
         sec_grp_rule = SecurityGroupRule(
-            **{'id': 'id', 'security_group_id': 'grp_id', 'description': 'desc',
-               'direction': 'dir', 'ethertype': 'eType',
+            **{'id': 'id', 'security_group_id': 'grp_id',
+               'description': 'desc', 'direction': 'dir', 'ethertype': 'eType',
                'port_range_min': '10.0.0.100', 'port_range_max': '10.0.0.200',
                'protocol': 'proto', 'remote_group_id': 'group_id',
                'remote_ip_prefix': 'ip_prefix'})