Advertisement
QualibreInfo

Untitled

Jan 9th, 2022
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. from __future__ import (absolute_import, division, print_function)
  2. __metaclass__ = type
  3.  
  4. import os
  5.  
  6. from units.compat import mock
  7. from units.compat import unittest
  8.  
  9. from ansible.modules import apt_key
  10.  
  11.  
  12. def returnc(x):
  13.     return 'C'
  14.  
  15.  
  16. class AptKeyTestCase(unittest.TestCase):
  17.  
  18.     @mock.patch.object(apt_key, 'apt_key_bin', '/usr/bin/apt-key')
  19.     @mock.patch.object(apt_key, 'lang_env', returnc)
  20.     @mock.patch.dict(os.environ, {'HTTP_PROXY': 'proxy.example.com'})
  21.     def test_import_key_with_http_proxy(self):
  22.         m_mock = mock.Mock()
  23.         m_mock.run_command.return_value = (0, '', '')
  24.         apt_key.import_key(
  25.             m_mock, keyring=None, keyserver='keyserver.example.com',
  26.             key_id='0xDEADBEEF')
  27.         self.assertEqual(
  28.             m_mock.run_command.call_args_list[0][0][0],
  29.             '/usr/bin/apt-key adv --no-tty --keyserver keyserver.example.com'
  30.             ' --keyserver-options http-proxy=proxy.example.com'
  31.             ' --recv 0xDEADBEEF'
  32.         )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement