def test_update(self, mock_qos_update): notifier = fake_notifier.get_fake_notifier() with mock.patch('cinder.rpc.get_notifier', return_value=notifier): req = fakes.HTTPRequest.blank('/v2/fake/qos-specs/555') body = {'qos_specs': {'key1': 'value1', 'key2': 'value2'}} res = self.controller.update(req, '555', body) self.assertDictMatch(res, body) self.assertEqual(1, notifier.get_notification_count())
def test_qos_specs_delete_inuse(self, mock_qos_delete, mock_qos_get_specs): req = fakes.HTTPRequest.blank('/v2/fake/qos-specs/666') notifier = fake_notifier.get_fake_notifier() with mock.patch('cinder.rpc.get_notifier', return_value=notifier): self.assertRaises(webob.exc.HTTPBadRequest, self.controller.delete, req, '666') self.assertEqual(1, notifier.get_notification_count())
def test_update_invalid_input(self, mock_qos_update): notifier = fake_notifier.get_fake_notifier() with mock.patch('cinder.rpc.get_notifier', return_value=notifier): req = fakes.HTTPRequest.blank('/v2/fake/qos-specs/888') body = {'qos_specs': {'key1': 'value1', 'key2': 'value2'}} self.assertRaises(webob.exc.HTTPBadRequest, self.controller.update, req, '888', body) self.assertEqual(1, notifier.get_notification_count())
def test_qos_specs_delete_keys(self, mock_qos_delete_keys): body = {"keys": ['bar', 'zoo']} req = fakes.HTTPRequest.blank('/v2/fake/qos-specs/666/delete_keys') notifier = fake_notifier.get_fake_notifier() with mock.patch('cinder.rpc.get_notifier', return_value=notifier): self.controller.delete_keys(req, '666', body) self.assertEqual(1, notifier.get_notification_count())
def test_qos_specs_delete_keys(self, mock_qos_delete_keys): body = {"keys": ['bar', 'zoo']} req = fakes.HTTPRequest.blank('/v2/fake/qos-specs/666/delete_keys') notifier = fake_notifier.get_fake_notifier() with mock.patch('cinder.rpc.get_notifier', return_value=notifier): self.controller.delete_keys(req, '666', body) self.assertEqual(1, notifier.get_notification_count())
def test_qos_specs_delete_not_found(self, mock_qos_delete, mock_qos_get_specs): notifier = fake_notifier.get_fake_notifier() with mock.patch('cinder.rpc.get_notifier', return_value=notifier): req = fakes.HTTPRequest.blank('/v2/fake/qos-specs/777') self.assertRaises(webob.exc.HTTPNotFound, self.controller.delete, req, '777') self.assertEqual(1, notifier.get_notification_count())
def test_update_failed(self, mock_qos_update): notifier = fake_notifier.get_fake_notifier() with mock.patch('cinder.rpc.get_notifier', return_value=notifier): req = fakes.HTTPRequest.blank('/v2/fake/qos-specs/999') body = {'qos_specs': {'key1': 'value1', 'key2': 'value2'}} self.assertRaises(webob.exc.HTTPInternalServerError, self.controller.update, req, '999', body) self.assertEqual(1, notifier.get_notification_count())
def test_update(self, mock_qos_update): notifier = fake_notifier.get_fake_notifier() with mock.patch('cinder.rpc.get_notifier', return_value=notifier): req = fakes.HTTPRequest.blank('/v2/fake/qos-specs/555') body = {'qos_specs': {'key1': 'value1', 'key2': 'value2'}} res = self.controller.update(req, '555', body) self.assertDictMatch(res, body) self.assertEqual(1, notifier.get_notification_count())
def test_create_failed(self, mock_qos_get_specs, mock_qos_spec_create): body = {"qos_specs": {"name": "555", "key1": "value1"}} req = fakes.HTTPRequest.blank('/v2/fake/qos-specs') notifier = fake_notifier.get_fake_notifier() with mock.patch('cinder.rpc.get_notifier', return_value=notifier): self.assertRaises(webob.exc.HTTPInternalServerError, self.controller.create, req, body) self.assertEqual(1, notifier.get_notification_count())
def test_qos_specs_delete_keys_badkey(self, mock_qos_specs_delete): req = fakes.HTTPRequest.blank('/v2/fake/qos-specs/666/delete_keys') body = {"keys": ['foo', 'zoo']} notifier = fake_notifier.get_fake_notifier() with mock.patch('cinder.rpc.get_notifier', return_value=notifier): self.assertRaises(webob.exc.HTTPBadRequest, self.controller.delete_keys, req, '666', body) self.assertEqual(1, notifier.get_notification_count())
def test_qos_specs_delete_keys_qos_notfound(self, mock_qos_specs_delete): body = {"keys": ['bar', 'zoo']} req = fakes.HTTPRequest.blank('/v2/fake/qos-specs/777/delete_keys') notifier = fake_notifier.get_fake_notifier() with mock.patch('cinder.rpc.get_notifier', return_value=notifier): self.assertRaises(webob.exc.HTTPNotFound, self.controller.delete_keys, req, '777', body) self.assertEqual(1, notifier.get_notification_count())
def test_update_not_found(self, mock_qos_update): notifier = fake_notifier.get_fake_notifier() with mock.patch('cinder.rpc.get_notifier', return_value=notifier): req = fakes.HTTPRequest.blank('/v2/fake/qos-specs/777') body = {'qos_specs': {'key1': 'value1', 'key2': 'value2'}} self.assertRaises(webob.exc.HTTPNotFound, self.controller.update, req, '777', body) self.assertEqual(1, notifier.get_notification_count())
def test_create_failed(self, mock_qos_get_specs, mock_qos_spec_create): body = {"qos_specs": {"name": "555", "key1": "value1"}} req = fakes.HTTPRequest.blank('/v2/fake/qos-specs') notifier = fake_notifier.get_fake_notifier() with mock.patch('cinder.rpc.get_notifier', return_value=notifier): self.assertRaises(webob.exc.HTTPInternalServerError, self.controller.create, req, body) self.assertEqual(1, notifier.get_notification_count())
def test_qos_specs_delete_keys_badkey(self, mock_qos_specs_delete): req = fakes.HTTPRequest.blank('/v2/fake/qos-specs/666/delete_keys') body = {"keys": ['foo', 'zoo']} notifier = fake_notifier.get_fake_notifier() with mock.patch('cinder.rpc.get_notifier', return_value=notifier): self.assertRaises(webob.exc.HTTPBadRequest, self.controller.delete_keys, req, '666', body) self.assertEqual(1, notifier.get_notification_count())
def test_qos_specs_delete_keys_qos_notfound(self, mock_qos_specs_delete): body = {"keys": ['bar', 'zoo']} req = fakes.HTTPRequest.blank('/v2/fake/qos-specs/777/delete_keys') notifier = fake_notifier.get_fake_notifier() with mock.patch('cinder.rpc.get_notifier', return_value=notifier): self.assertRaises(webob.exc.HTTPNotFound, self.controller.delete_keys, req, '777', body) self.assertEqual(1, notifier.get_notification_count())
def test_qos_specs_delete_inuse_force(self, mock_qos_delete, mock_qos_get_specs): req = fakes.HTTPRequest.blank('/v2/fake/qos-specs/666?force=True') notifier = fake_notifier.get_fake_notifier() with mock.patch('cinder.rpc.get_notifier', return_value=notifier): self.assertRaises(webob.exc.HTTPInternalServerError, self.controller.delete, req, '666') self.assertEqual(1, notifier.get_notification_count())
def test_create(self, mock_qos_get_specs, mock_qos_spec_create): body = {"qos_specs": {"name": "qos_specs_1", "key1": "value1"}} req = fakes.HTTPRequest.blank('/v2/fake/qos-specs') notifier = fake_notifier.get_fake_notifier() with mock.patch('cinder.rpc.get_notifier', return_value=notifier): res_dict = self.controller.create(req, body) self.assertEqual(1, notifier.get_notification_count()) self.assertEqual('qos_specs_1', res_dict['qos_specs']['name'])
def test_create(self, mock_qos_get_specs, mock_qos_spec_create): body = {"qos_specs": {"name": "qos_specs_1", "key1": "value1"}} req = fakes.HTTPRequest.blank('/v2/fake/qos-specs') notifier = fake_notifier.get_fake_notifier() with mock.patch('cinder.rpc.get_notifier', return_value=notifier): res_dict = self.controller.create(req, body) self.assertEqual(1, notifier.get_notification_count()) self.assertEqual('qos_specs_1', res_dict['qos_specs']['name'])
def test_qos_specs_delete(self, mock_qos_delete, mock_qos_get_specs): req = fakes.HTTPRequest.blank('/v2/fake/qos-specs/1') notifier = fake_notifier.get_fake_notifier() with mock.patch('cinder.rpc.get_notifier', return_value=notifier): self.controller.delete(req, 1) self.assertEqual(1, notifier.get_notification_count())
def test_qos_specs_delete(self, mock_qos_delete, mock_qos_get_specs): req = fakes.HTTPRequest.blank('/v2/fake/qos-specs/1') notifier = fake_notifier.get_fake_notifier() with mock.patch('cinder.rpc.get_notifier', return_value=notifier): self.controller.delete(req, 1) self.assertEqual(1, notifier.get_notification_count())