"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "cinder/tests/unit/api/contrib/test_services.py" between
cinder-17.0.0.tar.gz and cinder-17.0.1.tar.gz

About: OpenStack Cinder (Core Service: Block Storage) provides persistent block storage to running instances. Its pluggable driver architecture facilitates the creation and management of block storage devices.
The "Victoria" series (latest release).

test_services.py  (cinder-17.0.0):test_services.py  (cinder-17.0.1)
skipping to change at line 813 skipping to change at line 813
self.assertEqual(get_log_mock.return_value, res) self.assertEqual(get_log_mock.return_value, res)
get_log_mock.assert_called_once_with(req, mock.ANY, body=body) get_log_mock.assert_called_once_with(req, mock.ANY, body=body)
def test_get_log_wrong_binary(self): def test_get_log_wrong_binary(self):
req = FakeRequest(version=mv.LOG_LEVEL) req = FakeRequest(version=mv.LOG_LEVEL)
body = {'binary': 'wrong-binary'} body = {'binary': 'wrong-binary'}
self.assertRaises(exception.ValidationError, self.assertRaises(exception.ValidationError,
self.controller._get_log, req, self.context, self.controller._get_log, req, self.context,
body=body) body=body)
@mock.patch('cinder.api.contrib.services.ServiceController._get_log') def test_get_log_w_server_filter_same_host(self):
def test_get_log_w_server_filter(self, get_log_mock):
server_filter = 'controller-0' server_filter = 'controller-0'
CONF.set_override('host', server_filter)
body = {'host': CONF.host, 'server': server_filter} body = {'binary': constants.API_BINARY, 'server': server_filter}
req = FakeRequest(version=mv.LOG_LEVEL) req = FakeRequest(version=mv.LOG_LEVEL)
log_levels = self.controller._get_log(req, mock.sentinel.context, body) log_levels = self.controller._get_log(
req=req, context=mock.sentinel.context, body=body)
self.assertEqual(get_log_mock.return_value, log_levels) log_levels = log_levels['log_levels']
get_log_mock.assert_called_once_with(req, mock.sentinel.context, body)
self.assertNotEqual(log_levels['binary'], constants.API_BINARY) self.assertEqual(1, len(log_levels))
self.assertIsNot(log_levels, constants.API_BINARY) self.assertEqual('controller-0', log_levels[0]['host'])
self.assertEqual('cinder-api', log_levels[0]['binary'])
@mock.patch('cinder.api.contrib.services.ServiceController._get_log') # since there are a lot of log levels, we just check if the key-value
def test_get_log_w_server_equals_to_host(self, get_log_mock): # exists for levels
server_filter = 'server-0' self.assertIsNotNone(log_levels[0]['levels'])
body = {'host': CONF.host, 'server': server_filter} def test_get_log_w_server_filter_different_host(self):
server_filter = 'controller-0'
CONF.set_override('host', 'controller-different-host')
body = {'binary': constants.API_BINARY, 'server': server_filter}
req = FakeRequest(version=mv.LOG_LEVEL) req = FakeRequest(version=mv.LOG_LEVEL)
log_levels = self.controller._get_log(req, mock.sentinel.context, body) log_levels = self.controller._get_log(
req=req, context=mock.sentinel.context, body=body)
log_levels = log_levels['log_levels']
self.assertEqual(get_log_mock.return_value, log_levels) self.assertEqual(0, len(log_levels))
self.assertNotEqual(log_levels['binary'], constants.API_BINARY)
self.assertIsNot(log_levels, constants.API_BINARY)
@ddt.data(None, '', '*') @ddt.data(None, '', '*')
@mock.patch('cinder.objects.ServiceList.get_all') @mock.patch('cinder.objects.ServiceList.get_all')
def test__log_params_binaries_service_all(self, binary, service_list_mock): def test__log_params_binaries_service_all(self, binary, service_list_mock):
body = {'binary': binary, 'server': 'host1'} body = {'binary': binary, 'server': 'host1'}
binaries, services = self.controller._log_params_binaries_services( binaries, services = self.controller._log_params_binaries_services(
mock.sentinel.context, body) mock.sentinel.context, body)
self.assertEqual(constants.LOG_BINARIES, binaries) self.assertEqual(constants.LOG_BINARIES, binaries)
self.assertEqual(service_list_mock.return_value, services) self.assertEqual(service_list_mock.return_value, services)
service_list_mock.assert_called_once_with( service_list_mock.assert_called_once_with(
 End of changes. 6 change blocks. 
19 lines changed or deleted 21 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)