diff options
| author | Scott Moser <smoser@brickies.net> | 2020-06-08 12:49:12 -0400 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-08 10:49:12 -0600 | 
| commit | 3c551f6ebc12f7729a2755c89b19b9000e27cc88 (patch) | |
| tree | 0f7cd7ae6161791e7361e2bdffd38f414857f0c3 /tests/unittests/test_datasource/test_azure.py | |
| parent | 30aa1197c4c4d35d4ccf77d5d8854a40aa21219f (diff) | |
| download | vyos-cloud-init-3c551f6ebc12f7729a2755c89b19b9000e27cc88.tar.gz vyos-cloud-init-3c551f6ebc12f7729a2755c89b19b9000e27cc88.zip | |
Move subp into its own module. (#416)
This was painful, but it finishes a TODO from cloudinit/subp.py.
It moves the following from util to subp:
  ProcessExecutionError
  subp
  which
  target_path
I moved subp_blob_in_tempfile into cc_chef, which is its only caller.
That saved us from having to deal with it using write_file
and temp_utils from subp (which does not import any cloudinit things now).
It is arguable that 'target_path' could be moved to a 'path_utils' or
something, but in order to use it from subp and also from utils,
we had to get it out of utils.
Diffstat (limited to 'tests/unittests/test_datasource/test_azure.py')
| -rw-r--r-- | tests/unittests/test_datasource/test_azure.py | 30 | 
1 files changed, 15 insertions, 15 deletions
| diff --git a/tests/unittests/test_datasource/test_azure.py b/tests/unittests/test_datasource/test_azure.py index b9f4d8fd..05552a1e 100644 --- a/tests/unittests/test_datasource/test_azure.py +++ b/tests/unittests/test_datasource/test_azure.py @@ -491,7 +491,7 @@ scbus-1 on xpt0 bus 0              (dsaz, 'get_hostname', mock.MagicMock()),              (dsaz, 'set_hostname', mock.MagicMock()),              (dsaz, 'get_metadata_from_fabric', self.get_metadata_from_fabric), -            (dsaz.util, 'which', lambda x: True), +            (dsaz.subp, 'which', lambda x: True),              (dsaz.util, 'read_dmi_data', mock.MagicMock(                  side_effect=_dmi_mocks)),              (dsaz.util, 'wait_for_files', mock.MagicMock( @@ -1267,20 +1267,20 @@ scbus-1 on xpt0 bus 0          expected_config['config'].append(blacklist_config)          self.assertEqual(netconfig, expected_config) -    @mock.patch(MOCKPATH + 'util.subp') -    def test_get_hostname_with_no_args(self, subp): +    @mock.patch(MOCKPATH + 'subp.subp') +    def test_get_hostname_with_no_args(self, m_subp):          dsaz.get_hostname() -        subp.assert_called_once_with(("hostname",), capture=True) +        m_subp.assert_called_once_with(("hostname",), capture=True) -    @mock.patch(MOCKPATH + 'util.subp') -    def test_get_hostname_with_string_arg(self, subp): +    @mock.patch(MOCKPATH + 'subp.subp') +    def test_get_hostname_with_string_arg(self, m_subp):          dsaz.get_hostname(hostname_command="hostname") -        subp.assert_called_once_with(("hostname",), capture=True) +        m_subp.assert_called_once_with(("hostname",), capture=True) -    @mock.patch(MOCKPATH + 'util.subp') -    def test_get_hostname_with_iterable_arg(self, subp): +    @mock.patch(MOCKPATH + 'subp.subp') +    def test_get_hostname_with_iterable_arg(self, m_subp):          dsaz.get_hostname(hostname_command=("hostname",)) -        subp.assert_called_once_with(("hostname",), capture=True) +        m_subp.assert_called_once_with(("hostname",), capture=True)  class TestAzureBounce(CiTestCase): @@ -1302,7 +1302,7 @@ class TestAzureBounce(CiTestCase):              mock.patch.object(dsaz, 'get_metadata_from_imds',                                mock.MagicMock(return_value={})))          self.patches.enter_context( -            mock.patch.object(dsaz.util, 'which', lambda x: True)) +            mock.patch.object(dsaz.subp, 'which', lambda x: True))          self.patches.enter_context(mock.patch.object(              dsaz, '_get_random_seed', return_value='wild')) @@ -1331,7 +1331,7 @@ class TestAzureBounce(CiTestCase):          self.set_hostname = self.patches.enter_context(              mock.patch.object(dsaz, 'set_hostname'))          self.subp = self.patches.enter_context( -            mock.patch(MOCKPATH + 'util.subp')) +            mock.patch(MOCKPATH + 'subp.subp'))          self.find_fallback_nic = self.patches.enter_context(              mock.patch('cloudinit.net.find_fallback_nic', return_value='eth9')) @@ -1414,7 +1414,7 @@ class TestAzureBounce(CiTestCase):          cfg = {'hostname_bounce': {'policy': 'force'}}          dsrc = self._get_ds(self.get_ovf_env_with_dscfg(host_name, cfg),                              agent_command=['not', '__builtin__']) -        patch_path = MOCKPATH + 'util.which' +        patch_path = MOCKPATH + 'subp.which'          with mock.patch(patch_path) as m_which:              m_which.return_value = None              ret = self._get_and_setup(dsrc) @@ -1988,7 +1988,7 @@ class TestPreprovisioningPollIMDS(CiTestCase):          self.assertEqual(report_ready_func.call_count, 0) -@mock.patch(MOCKPATH + 'util.subp') +@mock.patch(MOCKPATH + 'subp.subp')  @mock.patch(MOCKPATH + 'util.write_file')  @mock.patch(MOCKPATH + 'util.is_FreeBSD')  @mock.patch('cloudinit.sources.helpers.netlink.' @@ -2159,7 +2159,7 @@ class TestWBIsPlatformViable(CiTestCase):              {'os.path.exists': False,               # Non-matching Azure chassis-asset-tag               'util.read_dmi_data': dsaz.AZURE_CHASSIS_ASSET_TAG + 'X', -             'util.which': None}, +             'subp.which': None},              dsaz._is_platform_viable, 'doesnotmatter'))          self.assertIn(              "DEBUG: Non-Azure DMI asset tag '{0}' discovered.\n".format( | 
