From: Tom Barron Date: Wed, 3 Feb 2016 22:14:23 +0000 (-0500) Subject: mock time.sleep in Broadcom unit test X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=4de6d18195ebcb3ead9a2cb03adeef36c0ef3a7b;p=openstack-build%2Fcinder-build.git mock time.sleep in Broadcom unit test TestBrcdHttpFCZoneClient.test_post_zone_data() invokes BrcdHTTPFCZoneClient.post_zone_data(), which in turn has a loop around its connect() method inside which there is a sleep(). Without time.sleep() mocked out, the test runs 7s on my laptop. This change mocks out time.sleep() in the test so that it now runs in .6s. Change-Id: Ib4c3a12b048a68d2c2db722c089eb04dd7d8c8ef --- diff --git a/cinder/tests/unit/zonemanager/test_brcd_http_fc_zone_client.py b/cinder/tests/unit/zonemanager/test_brcd_http_fc_zone_client.py index 67872f03b..739e377b5 100644 --- a/cinder/tests/unit/zonemanager/test_brcd_http_fc_zone_client.py +++ b/cinder/tests/unit/zonemanager/test_brcd_http_fc_zone_client.py @@ -15,6 +15,8 @@ # """Unit tests for brcd fc zone client http(s).""" +import time + from mock import patch from cinder import exception @@ -483,8 +485,9 @@ class TestBrcdHttpFCZoneClient(client.BrcdHTTPFCZoneClient, test.TestCase): self.assertRaises(exception.BrocadeZoningHttpException, self.delete_zones, delete_zones_info, False) + @patch.object(time, 'sleep') @patch.object(client.BrcdHTTPFCZoneClient, 'connect') - def test_post_zone_data(self, connect_mock): + def test_post_zone_data(self, connect_mock, sleep_mock): connect_mock.return_value = zone_post_page self.assertEqual( ("-1", "Name too long"), self.post_zone_data(zone_string_to_post))