1# Licensed under the Apache License, Version 2.0 (the "License"); you may 2# not use this file except in compliance with the License. You may obtain 3# a copy of the License at 4# 5# http://www.apache.org/licenses/LICENSE-2.0 6# 7# Unless required by applicable law or agreed to in writing, software 8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10# License for the specific language governing permissions and limitations 11# under the License. 12 13from openstack.compute.v2 import server_interface 14from openstack.tests.unit import base 15 16 17IDENTIFIER = 'IDENTIFIER' 18EXAMPLE = { 19 'fixed_ips': [ 20 { 21 'ip_address': '192.168.1.1', 22 'subnet_id': 'f8a6e8f8-c2ec-497c-9f23-da9616de54ef' 23 } 24 ], 25 'mac_addr': '2', 26 'net_id': '3', 27 'port_id': '4', 28 'port_state': '5', 29 'server_id': '6', 30 'tag': '7', 31} 32 33 34class TestServerInterface(base.TestCase): 35 36 def test_basic(self): 37 sot = server_interface.ServerInterface() 38 self.assertEqual('interfaceAttachment', sot.resource_key) 39 self.assertEqual('interfaceAttachments', sot.resources_key) 40 self.assertEqual('/servers/%(server_id)s/os-interface', sot.base_path) 41 self.assertTrue(sot.allow_create) 42 self.assertTrue(sot.allow_fetch) 43 self.assertFalse(sot.allow_commit) 44 self.assertTrue(sot.allow_delete) 45 self.assertTrue(sot.allow_list) 46 47 def test_make_it(self): 48 sot = server_interface.ServerInterface(**EXAMPLE) 49 self.assertEqual(EXAMPLE['fixed_ips'], sot.fixed_ips) 50 self.assertEqual(EXAMPLE['mac_addr'], sot.mac_addr) 51 self.assertEqual(EXAMPLE['net_id'], sot.net_id) 52 self.assertEqual(EXAMPLE['port_id'], sot.port_id) 53 self.assertEqual(EXAMPLE['port_state'], sot.port_state) 54 self.assertEqual(EXAMPLE['server_id'], sot.server_id) 55 self.assertEqual(EXAMPLE['tag'], sot.tag) 56