Speed up a slow test.

We had a test that was sleeping for around a second, this fudges
time.now() to make it look like it doesn't need to sleep.

Change-Id: I7f4b64ef906fcea50d88bfbf4c3f20f848b26274
This commit is contained in:
Daniel Watkins 2015-07-03 14:16:39 +01:00
parent 0208bc2a9f
commit e10de8835b
1 changed files with 17 additions and 0 deletions

View File

@ -6,9 +6,24 @@
import httpretty
from cloudinit import test
from cloudinit.tests.util import mock
from cloudinit import url_helper
class TimeJumpSideEffect(object):
def __init__(self, first_time, remaining_time):
def generator():
yield first_time
while True:
yield remaining_time
self.time = generator()
def __call__(self):
return next(self.time)
class UrlHelperWaitForUrlsTest(test.TestCase):
@httpretty.activate
@ -35,6 +50,8 @@ class UrlHelperWaitForUrlsTest(test.TestCase):
self.assertEqual(response.contents, b'it worked!')
@httpretty.activate
@mock.patch.object(
url_helper, 'now', mock.Mock(side_effect=TimeJumpSideEffect(0, 100)))
def test_url_wait_for_no_work(self):
def request_callback(request, uri, headers):