Fix test_scheduler_stats error module calls
It's great that the commit[1] brought in volume type filter. But the
commit made `test_scheduler_stats` didn't test anything for some
module call errors. The patch fixes it and lets all the tests in the module
work normally.
[1]https://github.com/openstack/cinder/commit/d5a3fdabca25a63bd3d01c86442ef649e7613aff
import ddt
import mock
+import webob
from cinder.api.contrib import scheduler_stats
from cinder.api.openstack import api_version_request as api_version
@@ -46,7 +47,7 @@ def schedule_rpcapi_get_pools(self, context, filters=None):
return all_pools
-@ddt.data
+@ddt.ddt
class SchedulerStatsAPITest(test.TestCase):
def setUp(self):
super(SchedulerStatsAPITest, self).setUp()
@@ -178,14 +179,14 @@ class SchedulerStatsAPITest(test.TestCase):
('3.35', True))
@ddt.unpack
@mock.patch('cinder.scheduler.rpcapi.SchedulerAPI.get_pools')
- @mock.patch('cinder.api.common.update_general_filters')
+ @mock.patch('cinder.api.common.reject_invalid_filters')
def test_get_pools_by_volume_type(self,
version,
support_volume_type,
- mock_update_filter,
+ mock_reject_invalid_filters,
mock_get_pools
):
- req = fakes.HTTPRequest.blank('/v3/%s/scheduler_stats?'
+ req = fakes.HTTPRequest.blank('/v3/%s/scheduler-stats/get_pools?'
'volume_type=lvm' % fake.PROJECT_ID)
mock_get_pools.return_value = [{'name': 'pool1',
'capabilities': {'foo': 'bar'}}]
@@ -197,10 +198,11 @@ class SchedulerStatsAPITest(test.TestCase):
'pools': [{'name': 'pool1'}]
}
- filters = None
+ filters = dict()
if support_volume_type:
filters = {'volume_type': 'lvm'}
- mock_update_filter.assert_called_once_with(self.ctxt, filters,
- 'pool')
+ filters = webob.multidict.MultiDict(filters)
+ mock_reject_invalid_filters.assert_called_once_with(self.ctxt, filters,
+ 'pool', True)
self.assertDictEqual(expected, res)
mock_get_pools.assert_called_with(mock.ANY, filters=filters)
