|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import random |
|
import sys |
|
import time |
|
|
|
|
|
|
|
|
|
|
|
if sys.version_info[:2] == (2, 6): |
|
import unittest2 as unittest |
|
else: |
|
import unittest |
|
|
|
|
|
|
|
if sys.version_info[0] == 2: |
|
import mock |
|
else: |
|
from unittest import mock |
|
|
|
|
|
def unique_id(name): |
|
""" |
|
Generate a unique ID that includes the given name, |
|
a timestamp and a random number. This helps when running |
|
integration tests in parallel that must create remote |
|
resources. |
|
""" |
|
return '{0}-{1}-{2}'.format(name, int(time.time()), |
|
random.randint(0, 10000)) |
|
|
|
|
|
class BaseTestCase(unittest.TestCase): |
|
""" |
|
A base test case which mocks out the low-level session to prevent |
|
any actual calls to Botocore. |
|
""" |
|
def setUp(self): |
|
self.bc_session_patch = mock.patch('botocore.session.Session') |
|
self.bc_session_cls = self.bc_session_patch.start() |
|
|
|
loader = self.bc_session_cls.return_value.get_component.return_value |
|
loader.data_path = '' |
|
self.loader = loader |
|
|
|
def tearDown(self): |
|
self.bc_session_patch.stop() |
|
|