This commit updates dcagent's test base structure for mocking, replacing the specific mock methods with the _mock_object function. Test plan: 1. PASS: Run tox -c distributedcloud/tox.ini -e py39 multiple times and verify that there isn't any test failures. Story: 2007082 Task: 51457 Change-Id: Ib222ca348134316ee15051adc609eff5e78b443f Signed-off-by: Raphael Lima <Raphael.Lima@windriver.com>
24 lines
576 B
Python
24 lines
576 B
Python
#
|
|
# Copyright (c) 2024 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
import mock
|
|
from oslotest import base
|
|
|
|
|
|
class DCAgentTestCase(base.BaseTestCase):
|
|
"""Test case base class for all unit tests."""
|
|
|
|
def setUp(self):
|
|
super().setUp()
|
|
|
|
def _mock_object(self, target, attribute, wraps=None):
|
|
"""Mock a specified target's attribute and return the mock object"""
|
|
|
|
mock_patch_object = mock.patch.object(target, attribute, wraps=wraps)
|
|
self.addCleanup(mock_patch_object.stop)
|
|
|
|
return mock_patch_object.start()
|