Mock time.sleep in unit tests

There are several unit tests taking excessive amounts of time due
to sleeps that aren't necessary during unit tests.  This change
mocks time.sleep so we aren't waiting for them.

Change-Id: I6108b51424a09509977a040689a348f2593e4a7a
This commit is contained in:
Ben Nemec 2017-02-06 22:11:46 +00:00
parent 17b5d6cd42
commit 2d1ae9da24
2 changed files with 7 additions and 0 deletions

View File

@ -54,6 +54,9 @@ class TestCheckHypervisorUtil(TestCase):
class TestWaitForStackUtil(TestCase):
def setUp(self):
self.mock_orchestration = mock.Mock()
sleep_patch = mock.patch('time.sleep')
self.addCleanup(sleep_patch.stop)
sleep_patch.start()
def mock_event(self, resource_name, id, resource_status_reason,
resource_status, event_time):

View File

@ -255,6 +255,10 @@ class TestOvercloudDeployPlan(utils.TestCommand):
self.mock_uuid4 = uuid4_patcher.start()
self.addCleanup(self.mock_uuid4.stop)
sleep_patch = mock.patch('time.sleep')
self.addCleanup(sleep_patch.stop)
sleep_patch.start()
@mock.patch('tripleoclient.utils.wait_for_stack_ready', autospec=True)
def test_overcloud_deploy_plan(self, mock_for_stack_ready):