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