Esempio n. 1
0
    def test__init__(self, mock_wrap, mock_clients):
        context = network_context.Network(self.get_context())
        self.assertEqual(context.net_wrapper, "foo_service")
        self.assertEqual(context.config["networks_per_tenant"], 1)
        self.assertEqual(context.config["start_cidr"],
                         network_context.Network.DEFAULT_CONFIG["start_cidr"])

        context = network_context.Network(
            self.get_context(start_cidr="foo_cidr", networks_per_tenant=42))
        self.assertEqual(context.net_wrapper, "foo_service")
        self.assertEqual(context.config["networks_per_tenant"], 42)
        self.assertEqual(context.config["start_cidr"], "foo_cidr")
Esempio n. 2
0
 def test_cleanup(self, mock_wrap, mock_osclients):
     net_context = network_context.Network(self.get_context())
     net_context.cleanup()
     mock_wrap().delete_network.assert_has_calls(
         [mock.call({"id": "foo_net"}),
          mock.call({"id": "bar_net"})],
         any_order=True)
Esempio n. 3
0
 def test_setup(self, mock_clients, mock_utils, mock_wrap):
     mock_utils.iterate_per_tenants.return_value = [
         ("foo_user", "foo_tenant"), ("bar_user", "bar_tenant")
     ]
     mock_create = mock.Mock(side_effect=lambda t, **kw: t + "-net")
     mock_wrap.return_value = mock.Mock(create_network=mock_create)
     nets_per_tenant = 2
     net_context = network_context.Network(
         self.get_context(networks_per_tenant=nets_per_tenant))
     net_context.setup()
     expected_networks = [["bar_tenant-net"] * nets_per_tenant,
                          ["foo_tenant-net"] * nets_per_tenant]
     actual_networks = []
     for tenant_id, tenant_ctx in (sorted(
             net_context.context["tenants"].items())):
         actual_networks.append(tenant_ctx["networks"])
     self.assertEqual(expected_networks, actual_networks)