MOE icon indicating copy to clipboard operation
MOE copied to clipboard

[Python] improve testing of OptimizableGpPrettyView.get_params_from_request()

Open suntzu86 opened this issue 10 years ago • 0 comments

OptimizableGpPrettyView.get_params_from_request() overrides the default GpPrettyView.get_params_from_request() behavior that just deserializes via colander.

The deserialization of optimization parameters is more complex b/c some child nodes of OptimizationInfo are dependent on other nodes for their types and similarly default values can change based on parameters NOT in OptimizationInfo.

As part of this complexity, self._route_name must be defined before executing get_params. This makes it hard to test.

At the moment, OptimizableGpPrettyView.get_params_from_request is tested in TestGpNextPointsViews.test_optimization_params_passed_through() (going thru a subclass of OptimizableGpPrettyView). We awkwardly build some objects, set a few names kind of arbitrarily, and do a bunch of unnecessary work just to call the function in the issue title.

So, fix this:

  • move the test so that only OptimizableGpPrettyView is constructed and mock out necessary components.

Note: colander improvements like #303 and/or #34 may allow us to substantially simplify this whole scheme.

suntzu86 avatar Jul 20 '14 01:07 suntzu86