Exemplo n.º 1
0
    def test_on_get_response_networkv2_private(self):
        """Test working path of NetworkV2()"""

        client, env = get_client_env(query_string='name=123321')
        net_vlan = client['Network_Vlan']
        net_vlan.getObject.return_value = {
            'id': 11,
            'name': 'Public Network',
            'subnets': [{
                'id': 1
            }, {
                'id': 3
            }, {
                'id': 5
            }],
            'vlanNumber': 999,
            'networkSpace': 'PRIVATE'
        }
        req = falcon.Request(env)
        resp = falcon.Response()

        networks.NetworkV2().on_get(req, resp, 11)

        self.check_response_body(resp.body['network'])
        self.assertEqual(resp.status, 200)
        self.assertEqual(resp.body['network']['provider:physical_network'],
                         True)
Exemplo n.º 2
0
def setup_routes(app, disp):
    # V2 Routes
    disp.set_handler('v2_network', networks.NetworkV2())
    disp.set_handler('v2_networks', networks.NetworksV2())
    disp.set_handler('v2_subnet', subnets.SubnetV2())
    disp.set_handler('v2_subnets', subnets.SubnetsV2())
    disp.set_handler('v2_extensions', extensions.ExtensionsV2())

    sl_common.add_hooks(app)
Exemplo n.º 3
0
    def test_on_get_response_networkv2_invalid_id(self):
        """Test invalid id"""
        client, env = get_client_env()

        req = api.Request(env, sl_client=client)
        resp = falcon.Response()

        networks.NetworkV2().on_get(req, resp, 'BAD_ID')
        self.assertEqual(resp.status, 400)
Exemplo n.º 4
0
def setup_routes(app, disp):
    # V2 Routes
    disp.set_handler('index', index.Index(app))
    disp.set_handler('v2_detail', versionv2.VersionV2(app))
    disp.set_handler('v2_network', networks.NetworkV2())
    disp.set_handler('v2_networks', networks.NetworksV2())
    disp.set_handler('v2_subnet', subnets.SubnetV2())
    disp.set_handler('v2_subnets', subnets.SubnetsV2())
    disp.set_handler('v2_extensions', extensions.ExtensionsV2())

    sl_common.add_hooks(app)
Exemplo n.º 5
0
    def test_on_get_response_networkv2_public(self):
        """Test working path of NetworkV2()"""
        client, env = get_client_env(query_string='name=123321')

        net_vlan = client['Network_Vlan']
        fake_net = get_fake_net()
        net_vlan.getObject.return_value = fake_net
        req = api.Request(env, sl_client=client)
        resp = falcon.Response()

        networks.NetworkV2().on_get(req, resp, fake_net['id'])
        self.assertEqual(resp.body['network'],
                         networks.format_network(fake_net, TENANT_ID))
        self.assertEqual(resp.status, 200)
        self.assertEqual(resp.body['network']['provider:physical_network'],
                         False)