diff options
author | Scott Moser <smoser@ubuntu.com> | 2018-05-23 16:04:42 -0400 |
---|---|---|
committer | Scott Moser <smoser@brickies.net> | 2018-05-23 16:04:42 -0400 |
commit | 12799d96f85e210c8e1216a3b06d8a98468fedd7 (patch) | |
tree | 54ab97e70752447a112f491c3fc1e10cbeb9bbec /tests/unittests/test_datasource/test_aliyun.py | |
parent | 3b28bdc616f3e7f4d6b419629dc7b9efc3ae8d1e (diff) | |
download | vyos-cloud-init-12799d96f85e210c8e1216a3b06d8a98468fedd7.tar.gz vyos-cloud-init-12799d96f85e210c8e1216a3b06d8a98468fedd7.zip |
tests: Avoid using https in httpretty, improve HttPretty test case.
On OpenSuSE 42.3, we would get errors running
tests/unittests/test_handler/test_handler_chef.py
- test_myhttps_nonet raises a UnmockedError
No mocking was registered, and real connections are not allowed
- test_myhttps_net raises SSLError
("bad handshake: SysCallError(32, 'EPIPE')",)
This fixes the errors by just using http instead of https.
Also it modifies the HttprettyTestCase to do the httpretty activate
and deactivate itself in setUp and tearDown. Then we don't have to
decorate individual test_ methods. Also, we set
httpretty.HTTPretty.allow_net_connect = False
Test cases here should not reach out to a network resource.
LP: #1771659
Diffstat (limited to 'tests/unittests/test_datasource/test_aliyun.py')
-rw-r--r-- | tests/unittests/test_datasource/test_aliyun.py | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/tests/unittests/test_datasource/test_aliyun.py b/tests/unittests/test_datasource/test_aliyun.py index 4fa9616b..1e77842f 100644 --- a/tests/unittests/test_datasource/test_aliyun.py +++ b/tests/unittests/test_datasource/test_aliyun.py @@ -130,7 +130,6 @@ class TestAliYunDatasource(test_helpers.HttprettyTestCase): self.ds.get_hostname()) @mock.patch("cloudinit.sources.DataSourceAliYun._is_aliyun") - @httpretty.activate def test_with_mock_server(self, m_is_aliyun): m_is_aliyun.return_value = True self.regist_default_server() @@ -143,7 +142,6 @@ class TestAliYunDatasource(test_helpers.HttprettyTestCase): self._test_host_name() @mock.patch("cloudinit.sources.DataSourceAliYun._is_aliyun") - @httpretty.activate def test_returns_false_when_not_on_aliyun(self, m_is_aliyun): """If is_aliyun returns false, then get_data should return False.""" m_is_aliyun.return_value = False |