]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Remove unneccessary Property constraints from unit tests
authorZane Bitter <zbitter@redhat.com>
Tue, 13 Aug 2013 08:48:15 +0000 (10:48 +0200)
committerZane Bitter <zbitter@redhat.com>
Tue, 13 Aug 2013 08:48:23 +0000 (10:48 +0200)
It doesn't really make a lot of sense to have constraints on the number of
keys in a Map Property, or on the allowed values in a List Property. In
both cases, we can and should define the Schema for each item. Neither is
used anywhere in the code, since the new Schema/Constraints do not allow
it, and SchemaTest.test_all_resource_schemata() tests that all existing
schemata are valid.

Change-Id: I24e11ec59c75ef770bf040ee8151bbe061f4a864

heat/tests/test_properties.py

index 944ef5ad7cf2dbe66537400f31b79230a5b3e493..5105a7fc22915258748f828774898520bb4929d2 100644 (file)
@@ -606,18 +606,6 @@ class PropertyTest(testtools.TestCase):
         p = properties.Property({'Type': 'List'})
         self.assertRaises(TypeError, p.validate_data, {'foo': 'bar'})
 
-    def test_list_value_list_bad(self):
-        schema = {'Type': 'List',
-                  'AllowedValues': ['foo', 'bar', 'baz']}
-        p = properties.Property(schema)
-        self.assertRaises(ValueError, p.validate_data, ['foo', 'wibble'])
-
-    def test_list_value_list_good(self):
-        schema = {'Type': 'List',
-                  'AllowedValues': ['foo', 'bar', 'baz']}
-        p = properties.Property(schema)
-        self.assertEqual(p.validate_data(['bar', 'foo']), ['bar', 'foo'])
-
     def test_list_maxlength_good(self):
         schema = {'Type': 'List',
                   'MaxLength': '3'}
@@ -657,44 +645,6 @@ class PropertyTest(testtools.TestCase):
         p = properties.Property({'Type': 'Map'})
         self.assertRaises(TypeError, p.validate_data, ['foo'])
 
-    def test_map_maxlength_good(self):
-        schema = {'Type': 'Map',
-                  'MaxLength': '4'}
-        p = properties.Property(schema)
-        self.assertEqual(
-            p.validate_data({'1': 'one', '2': 'two', '3': 'three'}),
-            {'1': 'one', '2': 'two', '3': 'three'})
-
-    def test_map_exceeded_maxlength(self):
-        schema = {'Type': 'Map',
-                  'MaxLength': '2'}
-        p = properties.Property(schema)
-        self.assertRaises(ValueError,
-                          p.validate_data,
-                          {'1': 'one', '2': 'two', '3': 'three'})
-
-    def test_map_length_in_range(self):
-        schema = {'Type': 'Map',
-                  'MinLength': '2',
-                  'MaxLength': '4'}
-        p = properties.Property(schema)
-        self.assertEqual(
-            p.validate_data({'1': 'one', '2': 'two', '3': 'three'}),
-            {'1': 'one', '2': 'two', '3': 'three'})
-
-    def test_map_minlength_good(self):
-        schema = {'Type': 'Map',
-                  'MinLength': '2'}
-        p = properties.Property(schema)
-        self.assertEqual(p.validate_data({'1': 'one', '2': 'two'}),
-                         {'1': 'one', '2': 'two'})
-
-    def test_map_smaller_than_minlength(self):
-        schema = {'Type': 'Map',
-                  'MinLength': '3'}
-        p = properties.Property(schema)
-        self.assertRaises(ValueError, p.validate_data, {'1': 'one'})
-
     def test_map_schema_good(self):
         map_schema = {'valid': {'Type': 'Boolean'}}
         p = properties.Property({'Type': 'Map', 'Schema': map_schema})