diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-02-13 19:50:03 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-02-13 19:50:03 +0000 |
| commit | 787e334a105c47bb387dc51c8798b4ac8e1d7bc0 (patch) | |
| tree | 4790e1037c69a189be5cc48af8c5dfc28b5a324b /nova/tests | |
| parent | 07e0c2421adf14d01389f5d6692ac2e18b8b7134 (diff) | |
| parent | 2c1bb9efd9287381f16979899bf25022822bf95b (diff) | |
Merge "Check the length of flavor name in "flavor-create""
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/test_instance_types.py | 11 | ||||
| -rw-r--r-- | nova/tests/test_utils.py | 15 |
2 files changed, 26 insertions, 0 deletions
diff --git a/nova/tests/test_instance_types.py b/nova/tests/test_instance_types.py index 0829df2c6..6ae28a1c9 100644 --- a/nova/tests/test_instance_types.py +++ b/nova/tests/test_instance_types.py @@ -142,6 +142,17 @@ class InstanceTypeTestCase(test.TestCase): self.assertRaises(exception.InvalidInput, instance_types.create, name, 256, 1, 120, 100, flavorid) + def test_instance_type_create_with_long_flavor_name(self): + # Flavor name with 255 characters or less is valid. + name = 'a' * 255 + inst_type = instance_types.create(name, 64, 1, 120, flavorid=11) + self.assertEqual(inst_type['name'], name) + + # Flavor name which is more than 255 characters will cause error. + name = 'a' * 256 + self.assertRaises(exception.InvalidInput, instance_types.create, + name, 64, 1, 120, flavorid=11) + def test_add_instance_type_access(self): user_id = 'fake' project_id = 'fake' diff --git a/nova/tests/test_utils.py b/nova/tests/test_utils.py index aaa826a70..8fb173385 100644 --- a/nova/tests/test_utils.py +++ b/nova/tests/test_utils.py @@ -964,3 +964,18 @@ class GetCallArgsTestCase(test.TestCase): self.assertEqual(3, callargs['red']) self.assertTrue('blue' in callargs) self.assertEqual(None, callargs['blue']) + + +class StringLengthTestCase(test.TestCase): + def test_check_string_length(self): + self.assertIsNone(utils.check_string_length( + 'test', 'name', max_length=255)) + self.assertRaises(exception.InvalidInput, + utils.check_string_length, + 11, 'name', max_length=255) + self.assertRaises(exception.InvalidInput, + utils.check_string_length, + '', 'name', min_length=1) + self.assertRaises(exception.InvalidInput, + utils.check_string_length, + 'a' * 256, 'name', max_length=255) |
