Last active
June 10, 2021 14:25
-
-
Save mgedmin/1a8eaf34cddc07cd8a7c29f13a7b654c to your computer and use it in GitHub Desktop.
Proposed unit test for https://github.com/ansible/ansible/pull/74949
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from units.compat import mock | |
from units.compat import unittest | |
from ansible.modules import apt_key | |
class AptKeyTestCase(unittest.TestCase): | |
@mock.patch.object(apt_key, 'apt_key_bin', '/usr/bin/apt-key') | |
@mock.patch.dict(os.environ, {'HTTP_PROXY': 'proxy.example.com'}) | |
def test_import_key_with_http_proxy(self): | |
m_mock = mock.Mock() | |
m_mock.run_command.return_value = (0, '', '') | |
apt_key.import_key( | |
m_mock, keyring=None, keyserver='keyserver.example.com', | |
key_id='0xDEADBEEF') | |
self.assertEqual( | |
m_mock.run_command.call_args_list[0][0][0], | |
'/usr/bin/apt-key adv --no-tty --keyserver keyserver.example.com' | |
' --keyserver-options http-proxy=proxy.example.com' | |
' --recv 0xDEADBEEF' | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's how this test fails on the devel branch (which is expected):
For some reason I'm unable to run it at all on the PR branch: