blob: 7af133664e9a02fb027376625fa447aee1a33743 [file] [log] [blame]
Roman Prykhodchenko62b1ed12013-10-16 21:51:47 +03001# -*- coding: utf-8 -*-
Roman Prykhodchenko62b1ed12013-10-16 21:51:47 +03002# Licensed under the Apache License, Version 2.0 (the "License"); you may
3# not use this file except in compliance with the License. You may obtain
4# a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11# License for the specific language governing permissions and limitations
12# under the License.
13
14from tempest.api.baremetal import base
15from tempest.common.utils import data_utils
16from tempest import exceptions as exc
17from tempest import test
18
19
20class TestChassis(base.BaseBaremetalTest):
21 """Tests for chassis."""
22
23 @test.attr(type='smoke')
24 def test_create_chassis(self):
25 descr = data_utils.rand_name('test-chassis-')
26 ch = self.create_chassis(description=descr)['chassis']
27
28 self.assertEqual(ch['description'], descr)
29
30 @test.attr(type='smoke')
31 def test_create_chassis_unicode_description(self):
32 # Use a unicode string for testing:
33 # 'We ♡ OpenStack in Ukraine'
34 descr = u'В Україні ♡ OpenStack!'
35 ch = self.create_chassis(description=descr)['chassis']
36
37 self.assertEqual(ch['description'], descr)
38
39 @test.attr(type='smoke')
40 def test_show_chassis(self):
41 descr = data_utils.rand_name('test-chassis-')
42 uuid = self.create_chassis(description=descr)['chassis']['uuid']
43
44 resp, chassis = self.client.show_chassis(uuid)
45
46 self.assertEqual(chassis['uuid'], uuid)
47 self.assertEqual(chassis['description'], descr)
48
49 @test.attr(type="smoke")
50 def test_list_chassis(self):
51 created_ids = [self.create_chassis()['chassis']['uuid']
52 for i in range(0, 5)]
53
54 resp, body = self.client.list_chassis()
55 loaded_ids = [ch['uuid'] for ch in body['chassis']]
56
57 for i in created_ids:
58 self.assertIn(i, loaded_ids)
59
60 @test.attr(type='smoke')
61 def test_delete_chassis(self):
62 uuid = self.create_chassis()['chassis']['uuid']
63
64 self.delete_chassis(uuid)
65
66 self.assertRaises(exc.NotFound, self.client.show_chassis, uuid)
67
68 @test.attr(type='smoke')
69 def test_update_chassis(self):
70 chassis_id = self.create_chassis()['chassis']['uuid']
71
72 new_description = data_utils.rand_name('new-description-')
73 self.client.update_chassis(chassis_id, description=new_description)
74
75 resp, chassis = self.client.show_chassis(chassis_id)
76 self.assertEqual(chassis['description'], new_description)