Revision bfb3f9c2 snf-cyclades-app/synnefo/logic/tests/networks.py

b/snf-cyclades-app/synnefo/logic/tests/networks.py
45 45
        kwargs = {
46 46
            "name": "test",
47 47
            "userid": "user",
48
            "subnet": "192.168.20.0/24",
49 48
            "flavor": "CUSTOM",
50 49
        }
51
        # wrong gateway
52
        kw = copy(kwargs)
53
        kw["gateway"] = "192.168.3.1"
54
        self.assertRaises(faults.BadRequest, networks.create, **kw)
55
        # wrong subnet
56
        kw = copy(kwargs)
57
        kw["subnet"] = "192.168.2.0"
58
        self.assertRaises(faults.OverLimit, networks.create, **kw)
59
        kw["subnet"] = "192.168.0.0/16"
60
        self.assertRaises(faults.OverLimit, networks.create, **kw)
61
        kw["subnet"] = "192.168.0.3/24"
62
        self.assertRaises(faults.BadRequest, networks.create, **kw)
63 50
        # wrong flavor
64 51
        kw = copy(kwargs)
65 52
        kw["flavor"] = "UNKNOWN"
66 53
        self.assertRaises(faults.BadRequest, networks.create, **kw)
67 54
        # Test create objet
68
        kwargs["gateway"] = "192.168.20.1"
69 55
        kwargs["public"] = True
70
        kwargs["dhcp"] = False
71 56
        with mocked_quotaholder():
72 57
            net = networks.create(**kwargs)
73
        self.assertEqual(net.subnet4, "192.168.20.0/24")
74
        self.assertEqual(net.subnets.get(ipversion=4).gateway, "192.168.20.1")
75 58
        self.assertEqual(net.public, True)
76 59
        self.assertEqual(net.flavor, "CUSTOM")
77
        self.assertEqual(net.subnets.get(ipversion=4).dhcp, False)
78 60
        self.assertEqual(net.action, "CREATE")
79 61
        self.assertEqual(net.state, "ACTIVE")
80 62
        self.assertEqual(net.name, "test")
......
126 108
        self.assertEqual(net.mac_prefix, settings.DEFAULT_MAC_PREFIX)
127 109
        self.assertEqual(net.link, settings.DEFAULT_BRIDGE)
128 110
        self.assertEqual(net.backend_tag, [])
129

  
130
    def test_create_network_ipv6(self):
131
        kwargs = {
132
            "name": "test",
133
            "userid": "user",
134
            "flavor": "CUSTOM",
135
            "subnet6": "2001:648:2ffc:1112::/64",
136
        }
137
        # Wrong subnet
138
        kw = copy(kwargs)
139
        kw["subnet6"] = "2001:64q:2ffc:1112::/64"
140
        self.assertRaises(faults.BadRequest, networks.create, **kw)
141
        # Wrong gateway
142
        kw = copy(kwargs)
143
        kw["gateway6"] = "2001:64q:2ffc:1119::1"
144
        self.assertRaises(faults.BadRequest, networks.create, **kw)
145
        # floating_ip_pools cannot be ipv6 only
146
        kw = copy(kwargs)
147
        kw["floating_ip_pool"] = True
148
        self.assertRaises(faults.BadRequest, networks.create, **kw)
149
        kwargs["gateway6"] = "2001:648:2ffc:1112::1"
150
        with mocked_quotaholder():
151
            net = networks.create(**kwargs)
152
        subnet6 = net.subnets.get(ipversion=6)
153
        self.assertEqual(subnet6.cidr, "2001:648:2ffc:1112::/64")
154
        self.assertEqual(subnet6.gateway, "2001:648:2ffc:1112::1")
155
        self.assertEqual(net.get_ip_pools(), [])

Also available in: Unified diff