1
# Copyright (C) 2011 Midokura KK
4
# Licensed under the Apache License, Version 2.0 (the "License"); you may
5
# not use this file except in compliance with the License. You may obtain
6
# a copy of the License at
8
# http://www.apache.org/licenses/LICENSE-2.0
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
# License for the specific language governing permissions and limitations
21
from nova import compute
22
from nova.tests.api.openstack import fakes
23
from nova.api.openstack.contrib.virtual_interfaces import \
24
ServerVirtualInterfaceController
27
def compute_api_get(self, context, server_id):
28
return {'virtual_interfaces': [
29
{'uuid': '00000000-0000-0000-0000-00000000000000000',
30
'address': '00-00-00-00-00-00'},
31
{'uuid': '11111111-1111-1111-1111-11111111111111111',
32
'address': '11-11-11-11-11-11'}]}
35
class ServerVirtualInterfaceTest(test.TestCase):
38
super(ServerVirtualInterfaceTest, self).setUp()
39
self.controller = ServerVirtualInterfaceController()
40
self.stubs.Set(compute.api.API, "get", compute_api_get)
43
super(ServerVirtualInterfaceTest, self).tearDown()
45
def test_get_virtual_interfaces_list(self):
46
req = webob.Request.blank('/v1.1/servers/1/os-virtual-interfaces')
47
res = req.get_response(fakes.wsgi_app())
48
self.assertEqual(res.status_int, 200)
49
res_dict = json.loads(res.body)
50
response = {'virtual_interfaces': [
51
{'id': '00000000-0000-0000-0000-00000000000000000',
52
'mac_address': '00-00-00-00-00-00'},
53
{'id': '11111111-1111-1111-1111-11111111111111111',
54
'mac_address': '11-11-11-11-11-11'}]}
55
self.assertEqual(res_dict, response)