Skip to content

Commit 342e0de

Browse files
committed
network version resource
Change-Id: I19896c3115385a2b8bf0973809cfbc357ffc8b40
1 parent 4c01c6b commit 342e0de

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

openstack/network/version.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
from openstack.network import network_service
14+
from openstack import resource
15+
16+
17+
class Version(resource.Resource):
18+
resource_key = 'version'
19+
resources_key = 'versions'
20+
base_path = '/'
21+
service = network_service.NetworkService()
22+
23+
# capabilities
24+
allow_list = True
25+
26+
# Properties
27+
links = resource.prop('links')
28+
status = resource.prop('status')
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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.network import version
16+
17+
IDENTIFIER = 'v2.0'
18+
EXAMPLE = {
19+
'id': IDENTIFIER,
20+
'links': '2',
21+
'status': '3',
22+
}
23+
24+
25+
class TestVersion(testtools.TestCase):
26+
27+
def test_basic(self):
28+
sot = version.Version()
29+
self.assertEqual('version', sot.resource_key)
30+
self.assertEqual('versions', sot.resources_key)
31+
self.assertEqual('/', sot.base_path)
32+
self.assertEqual('network', sot.service.service_type)
33+
self.assertFalse(sot.allow_create)
34+
self.assertFalse(sot.allow_retrieve)
35+
self.assertFalse(sot.allow_update)
36+
self.assertFalse(sot.allow_delete)
37+
self.assertTrue(sot.allow_list)
38+
39+
def test_make_it(self):
40+
sot = version.Version(EXAMPLE)
41+
self.assertEqual(EXAMPLE['id'], sot.id)
42+
self.assertEqual(EXAMPLE['links'], sot.links)
43+
self.assertEqual(EXAMPLE['status'], sot.status)

0 commit comments

Comments
 (0)