summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2014-07-24 08:49:42 -0400
committerScott Moser <smoser@ubuntu.com>2014-07-24 08:49:42 -0400
commit84ee0821f32c652fd377663c2e73658437ae99ab (patch)
treecbebe02dbaa15307c9992d068a714613be2fdce1 /tests
parenta000671207ee4a445261b05d22c2f3357b413053 (diff)
parent27ce1e10692e93cfb9b87df547de4e0930ec4d28 (diff)
downloadvyos-cloud-init-84ee0821f32c652fd377663c2e73658437ae99ab.tar.gz
vyos-cloud-init-84ee0821f32c652fd377663c2e73658437ae99ab.zip
merge from trunk
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/helpers.py15
-rw-r--r--tests/unittests/test_datasource/test_gce.py3
-rw-r--r--tests/unittests/test_datasource/test_openstack.py2
-rw-r--r--tests/unittests/test_ec2_util.py2
4 files changed, 19 insertions, 3 deletions
diff --git a/tests/unittests/helpers.py b/tests/unittests/helpers.py
index 970eb8cb..9700a4ca 100644
--- a/tests/unittests/helpers.py
+++ b/tests/unittests/helpers.py
@@ -233,6 +233,21 @@ class FilesystemMockingTestCase(ResourceUsingTestCase):
self.patched_funcs.append((mod, f, func))
+class HttprettyTestCase(TestCase):
+ # necessary as http_proxy gets in the way of httpretty
+ # https://github.com/gabrielfalcao/HTTPretty/issues/122
+ def setUp(self):
+ self.restore_proxy = os.environ.get('http_proxy')
+ if self.restore_proxy is not None:
+ del os.environ['http_proxy']
+ super(HttprettyTestCase, self).setUp()
+
+ def tearDown(self):
+ if self.restore_proxy:
+ os.environ['http_proxy'] = self.restore_proxy
+ super(HttprettyTestCase, self).tearDown()
+
+
def populate_dir(path, files):
if not os.path.exists(path):
os.makedirs(path)
diff --git a/tests/unittests/test_datasource/test_gce.py b/tests/unittests/test_datasource/test_gce.py
index 405dfbdb..60a0ce48 100644
--- a/tests/unittests/test_datasource/test_gce.py
+++ b/tests/unittests/test_datasource/test_gce.py
@@ -55,12 +55,13 @@ def _request_callback(method, uri, headers):
return (404, headers, '')
-class TestDataSourceGCE(test_helpers.TestCase):
+class TestDataSourceGCE(test_helpers.HttprettyTestCase):
def setUp(self):
self.ds = DataSourceGCE.DataSourceGCE(
settings.CFG_BUILTIN, None,
helpers.Paths({}))
+ super(TestDataSourceGCE, self).setUp()
@httpretty.activate
def test_connection(self):
diff --git a/tests/unittests/test_datasource/test_openstack.py b/tests/unittests/test_datasource/test_openstack.py
index c5298aaa..c088bb55 100644
--- a/tests/unittests/test_datasource/test_openstack.py
+++ b/tests/unittests/test_datasource/test_openstack.py
@@ -121,7 +121,7 @@ def _register_uris(version, ec2_files, ec2_meta, os_files):
body=get_request_callback)
-class TestOpenStackDataSource(test_helpers.TestCase):
+class TestOpenStackDataSource(test_helpers.HttprettyTestCase):
VERSION = 'latest'
@hp.activate
diff --git a/tests/unittests/test_ec2_util.py b/tests/unittests/test_ec2_util.py
index 26cd12ec..700254a3 100644
--- a/tests/unittests/test_ec2_util.py
+++ b/tests/unittests/test_ec2_util.py
@@ -6,7 +6,7 @@ from cloudinit import url_helper as uh
import httpretty as hp
-class TestEc2Util(helpers.TestCase):
+class TestEc2Util(helpers.HttprettyTestCase):
VERSION = 'latest'
@hp.activate