python-tripleoclient/tripleoclient/tests/v1/overcloud_node/fakes.py

59 lines
1.9 KiB
Python

# Copyright 2015 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
import mock
from osc_lib.tests import utils
from tripleoclient import plugin
from tripleoclient.tests import fakes
class FakeClientWrapper(object):
def __init__(self):
self._instance = mock.Mock()
self._mock_websocket = mock.Mock()
self._mock_websocket.__enter__ = mock.Mock(
return_value=self._mock_websocket)
# Return False to avoid silencing exceptions
self._mock_websocket.__exit__ = mock.Mock(return_value=False)
def messaging_websocket(self):
return self._mock_websocket
class TestDeleteNode(utils.TestCommand):
def setUp(self):
super(TestDeleteNode, self).setUp()
self.app.client_manager.auth_ref = mock.Mock(auth_token="TOKEN")
self.app.client_manager.orchestration = mock.Mock()
self.app.client_manager.tripleoclient = FakeClientWrapper()
class TestOvercloudNode(utils.TestCommand):
def setUp(self):
super(TestOvercloudNode, self).setUp()
self.app.client_manager.baremetal = mock.Mock()
self.app.client_manager.workflow_engine = mock.Mock()
tc = self.app.client_manager.tripleoclient = FakeClientWrapper()
tc.create_mistral_context = plugin.ClientWrapper(
instance=fakes.FakeInstanceData
).create_mistral_context