blob: b537baae73b525ab78e90ac05934ee71d82f444b [file] [log] [blame]
Reedip Banerjee6cca2d02015-08-28 09:24:47 +05301# Copyright 2015 NEC Corporation. All rights reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
Ken'ichi Ohmichi50f82952015-09-14 17:04:46 +000015from tempest_lib.tests import fake_auth_provider
16
Reedip Banerjee6cca2d02015-08-28 09:24:47 +053017from tempest.services.compute.json import fixed_ips_client
Reedip Banerjee6cca2d02015-08-28 09:24:47 +053018from tempest.tests.services.compute import base
19
20
21class TestFixedIPsClient(base.BaseComputeServiceTest):
22 FIXED_IP_INFO = {"fixed_ip": {"address": "10.0.0.1",
23 "cidr": "10.11.12.0/24",
24 "host": "localhost",
25 "hostname": "OpenStack"}}
26
27 def setUp(self):
28 super(TestFixedIPsClient, self).setUp()
29 fake_auth = fake_auth_provider.FakeAuthProvider()
30 self.fixedIPsClient = (fixed_ips_client.
31 FixedIPsClient
32 (fake_auth, 'compute',
33 'regionOne'))
34
35 def _test_show_fixed_ip(self, bytes_body=False):
36 self.check_service_client_function(
37 self.fixedIPsClient.show_fixed_ip,
38 'tempest.common.service_client.ServiceClient.get',
39 self.FIXED_IP_INFO, bytes_body,
40 status=200, fixed_ip='Identifier')
41
42 def test_show_fixed_ip_with_str_body(self):
43 self._test_show_fixed_ip()
44
45 def test_show_fixed_ip_with_bytes_body(self):
46 self._test_show_fixed_ip(True)
ghanshyam31e74f32015-10-09 11:19:54 +090047
48 def _test_reserve_fixed_ip(self, bytes_body=False):
49 self.check_service_client_function(
50 self.fixedIPsClient.reserve_fixed_ip,
51 'tempest.common.service_client.ServiceClient.post',
52 {}, bytes_body,
53 status=202, fixed_ip='Identifier')
54
55 def test_reserve_fixed_ip_with_str_body(self):
56 self._test_reserve_fixed_ip()
57
58 def test_reserve_fixed_ip_with_bytes_body(self):
59 self._test_reserve_fixed_ip(True)