Example #1
0
 def _validate(self, val):
     # Parent classes must do validation to check that the object type here
     # matches the object type of the parameter with the corresponding name.
     object_class = get_object_class(val.obj_type)
     return ParamChange(
         obj_type=val.obj_type, name=val.name,
         values=[object_class.normalize(value) for value in val.values])
Example #2
0
 def _validate(self, val):
     object_class = get_object_class(val.obj_type)
     return Parameter(
         obj_type=val.obj_type,
         values=[object_class.normalize(value) for value in val.values],
         name=val.name, description=val.description)
Example #3
0
 def _pre_put_hook(self):
     """Does validation before the model is put into the datastore."""
     object_class = get_object_class(self.obj_type)
     self.values = [object_class.normalize(value) for value in self.values]
Example #4
0
 def test_base_object_is_not_gettable(self):
     """Tests that BaseObject exists and cannot be set as an obj_type."""
     assert getattr(objects, 'BaseObject')
     with self.assertRaises(TypeError):
         types.get_object_class('BaseObject')
Example #5
0
 def test_fake_class_is_not_gettable(self):
     """Tests that trying to retrieve a fake class raises an error."""
     with self.assertRaises(TypeError):
         types.get_object_class('FakeClass')
Example #6
0
 def test_get_object_class_method(self):
     """Tests the normal behavior of get_object_class()."""
     IntClass = types.get_object_class('Int')
     assert IntClass.__name__ == 'Int'