summaryrefslogtreecommitdiff
path: root/nova
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-04-11 07:04:40 +0000
committerGerrit Code Review <review@openstack.org>2014-04-11 07:04:40 +0000
commit603e099af58fe367d7d906af2f91c9356838e8c8 (patch)
tree3d3b3ec912ca3a3192ddf0b3327642971b19847f /nova
parent41c0faf89d1f054ed6a9b976b0214715fcad2716 (diff)
parenta43d5ea900d56d26b07a9959ce1834a67d47c2ec (diff)
downloadnova-603e099af58fe367d7d906af2f91c9356838e8c8.tar.gz
Merge "Add test cases for validate_extra_spec_keys"
Diffstat (limited to 'nova')
-rw-r--r--nova/tests/compute/test_flavors.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/nova/tests/compute/test_flavors.py b/nova/tests/compute/test_flavors.py
new file mode 100644
index 0000000000..69eb8ec3ed
--- /dev/null
+++ b/nova/tests/compute/test_flavors.py
@@ -0,0 +1,38 @@
+# Copyright 2014 IBM Corp.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+"""Tests for flavor basic functions"""
+
+from nova.compute import flavors
+from nova import exception
+from nova import test
+
+
+class ExtraSpecTestCase(test.NoDBTestCase):
+ def setUp(self):
+ super(ExtraSpecTestCase, self).setUp()
+
+ def _flavor_validate_extra_spec_keys_invalid_input(self, key_name_list):
+ self.assertRaises(exception.InvalidInput,
+ flavors.validate_extra_spec_keys, key_name_list)
+
+ def test_flavor_validate_extra_spec_keys_invalid_input(self):
+ lists = [['', ], ['*', ], ['+', ]]
+ for x in lists:
+ self._flavor_validate_extra_spec_keys_invalid_input(x)
+
+ def test_flavor_validate_extra_spec_keys(self):
+ key_name_list = ['abc', 'ab c', 'a-b-c', 'a_b-c', 'a:bc']
+ flavors.validate_extra_spec_keys(key_name_list)