示例#1
0
    def test_dpkg_reconfigure_does_reconfigure(self, m_subp):
        target = "/foo-target"

        # due to the way the cleaners are called (via dictionary reference)
        # mocking clean_cloud_init directly does not work.  So we mock
        # the CONFIG_CLEANERS dictionary and assert our cleaner is called.
        ci_cleaner = mock.MagicMock()
        with mock.patch.dict(("cloudinit.config.cc_apt_configure."
                              "CONFIG_CLEANERS"),
                             values={'cloud-init': ci_cleaner}, clear=True):
            cc_apt_configure.dpkg_reconfigure(['pkga', 'cloud-init'],
                                              target=target)
        # cloud-init is actually the only package we have a cleaner for
        # so for now, its the only one that should reconfigured
        self.assertTrue(m_subp.called)
        ci_cleaner.assert_called_with(target)
        self.assertEqual(m_subp.call_count, 1)
        found = m_subp.call_args_list[0][0][0]
        expected = ['dpkg-reconfigure', '--frontend=noninteractive',
                    'cloud-init']
        self.assertEqual(expected, found)
示例#2
0
    def test_dpkg_reconfigure_does_reconfigure(self, m_subp):
        target = "/foo-target"

        # due to the way the cleaners are called (via dictionary reference)
        # mocking clean_cloud_init directly does not work.  So we mock
        # the CONFIG_CLEANERS dictionary and assert our cleaner is called.
        ci_cleaner = mock.MagicMock()
        with mock.patch.dict(("cloudinit.config.cc_apt_configure."
                              "CONFIG_CLEANERS"),
                             values={'cloud-init': ci_cleaner}, clear=True):
            cc_apt_configure.dpkg_reconfigure(['pkga', 'cloud-init'],
                                              target=target)
        # cloud-init is actually the only package we have a cleaner for
        # so for now, its the only one that should reconfigured
        self.assertTrue(m_subp.called)
        ci_cleaner.assert_called_with(target)
        self.assertEqual(m_subp.call_count, 1)
        found = m_subp.call_args_list[0][0][0]
        expected = ['dpkg-reconfigure', '--frontend=noninteractive',
                    'cloud-init']
        self.assertEqual(expected, found)
示例#3
0
 def test_dpkg_reconfigure_not_done_if_no_cleaners(self, m_subp):
     cc_apt_configure.dpkg_reconfigure(['pkgfoo', 'pkgbar'])
     m_subp.assert_not_called()
示例#4
0
 def test_dpkg_reconfigure_not_done_on_no_data(self, m_subp):
     cc_apt_configure.dpkg_reconfigure([])
     m_subp.assert_not_called()
示例#5
0
 def test_dpkg_reconfigure_not_done_if_no_cleaners(self, m_subp):
     cc_apt_configure.dpkg_reconfigure(['pkgfoo', 'pkgbar'])
     m_subp.assert_not_called()
示例#6
0
 def test_dpkg_reconfigure_not_done_on_no_data(self, m_subp):
     cc_apt_configure.dpkg_reconfigure([])
     m_subp.assert_not_called()