|
| 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 | + |
| 13 | +import testtools |
| 14 | + |
| 15 | +from openstack.bare_metal.v1 import port |
| 16 | + |
| 17 | +FAKE = { |
| 18 | + "address": "11:11:11:11:11:11", |
| 19 | + "created_at": "2016-08-18T22:28:49.946416+00:00", |
| 20 | + "extra": {}, |
| 21 | + "internal_info": {}, |
| 22 | + "links": [ |
| 23 | + { |
| 24 | + "href": "http://127.0.0.1:6385/v1/ports/<PORT_ID>", |
| 25 | + "rel": "self" |
| 26 | + }, |
| 27 | + { |
| 28 | + "href": "http://127.0.0.1:6385/ports/<PORT_ID>", |
| 29 | + "rel": "bookmark" |
| 30 | + } |
| 31 | + ], |
| 32 | + "local_link_connection": { |
| 33 | + "port_id": "Ethernet3/1", |
| 34 | + "switch_id": "0a:1b:2c:3d:4e:5f", |
| 35 | + "switch_info": "switch1" |
| 36 | + }, |
| 37 | + "node_uuid": "6d85703a-565d-469a-96ce-30b6de53079d", |
| 38 | + "portgroup_uuid": "e43c722c-248e-4c6e-8ce8-0d8ff129387a", |
| 39 | + "pxe_enabled": True, |
| 40 | + "updated_at": None, |
| 41 | + "uuid": "d2b30520-907d-46c8-bfee-c5586e6fb3a1" |
| 42 | +} |
| 43 | + |
| 44 | + |
| 45 | +class TestPort(testtools.TestCase): |
| 46 | + |
| 47 | + def test_basic(self): |
| 48 | + sot = port.Port() |
| 49 | + self.assertIsNone(sot.resource_key) |
| 50 | + self.assertEqual('ports', sot.resources_key) |
| 51 | + self.assertEqual('/ports', sot.base_path) |
| 52 | + self.assertEqual('baremetal', sot.service.service_type) |
| 53 | + self.assertTrue(sot.allow_create) |
| 54 | + self.assertTrue(sot.allow_get) |
| 55 | + self.assertTrue(sot.allow_update) |
| 56 | + self.assertTrue(sot.allow_delete) |
| 57 | + self.assertTrue(sot.allow_list) |
| 58 | + self.assertTrue(sot.patch_update) |
| 59 | + |
| 60 | + def test_instantiate(self): |
| 61 | + sot = port.PortDetail(**FAKE) |
| 62 | + self.assertEqual(FAKE['uuid'], sot.id) |
| 63 | + self.assertEqual(FAKE['address'], sot.address) |
| 64 | + self.assertEqual(FAKE['created_at'], sot.created_at) |
| 65 | + self.assertEqual(FAKE['extra'], sot.extra) |
| 66 | + self.assertEqual(FAKE['internal_info'], sot.internal_info) |
| 67 | + self.assertEqual(FAKE['links'], sot.links) |
| 68 | + self.assertEqual(FAKE['local_link_connection'], |
| 69 | + sot.local_link_connection) |
| 70 | + self.assertEqual(FAKE['node_uuid'], sot.node_id) |
| 71 | + self.assertEqual(FAKE['portgroup_uuid'], sot.port_group_id) |
| 72 | + self.assertEqual(FAKE['pxe_enabled'], sot.is_pxe_enabled) |
| 73 | + self.assertEqual(FAKE['updated_at'], sot.updated_at) |
| 74 | + |
| 75 | + |
| 76 | +class TestPortDetail(testtools.TestCase): |
| 77 | + |
| 78 | + def test_basic(self): |
| 79 | + sot = port.PortDetail() |
| 80 | + self.assertIsNone(sot.resource_key) |
| 81 | + self.assertEqual('ports', sot.resources_key) |
| 82 | + self.assertEqual('/ports/detail', sot.base_path) |
| 83 | + self.assertEqual('baremetal', sot.service.service_type) |
| 84 | + self.assertFalse(sot.allow_create) |
| 85 | + self.assertFalse(sot.allow_get) |
| 86 | + self.assertFalse(sot.allow_update) |
| 87 | + self.assertFalse(sot.allow_delete) |
| 88 | + self.assertTrue(sot.allow_list) |
| 89 | + |
| 90 | + def test_instantiate(self): |
| 91 | + sot = port.PortDetail(**FAKE) |
| 92 | + self.assertEqual(FAKE['uuid'], sot.id) |
| 93 | + self.assertEqual(FAKE['address'], sot.address) |
| 94 | + self.assertEqual(FAKE['created_at'], sot.created_at) |
| 95 | + self.assertEqual(FAKE['extra'], sot.extra) |
| 96 | + self.assertEqual(FAKE['internal_info'], sot.internal_info) |
| 97 | + self.assertEqual(FAKE['links'], sot.links) |
| 98 | + self.assertEqual(FAKE['local_link_connection'], |
| 99 | + sot.local_link_connection) |
| 100 | + self.assertEqual(FAKE['node_uuid'], sot.node_id) |
| 101 | + self.assertEqual(FAKE['portgroup_uuid'], sot.port_group_id) |
| 102 | + self.assertEqual(FAKE['pxe_enabled'], sot.is_pxe_enabled) |
| 103 | + self.assertEqual(FAKE['updated_at'], sot.updated_at) |
0 commit comments