コード例 #1
0
 def test_ntp_rename_ntp_conf_skip_missing(self):
     """When NTP_CONF doesn't exist rename_ntp doesn't create a file."""
     ntpconf = self.tmp_path("ntp.conf", self.new_root)
     self.assertFalse(os.path.exists(ntpconf))
     cc_ntp.rename_ntp_conf(confpath=ntpconf)
     self.assertFalse(os.path.exists("{0}.dist".format(ntpconf)))
     self.assertFalse(os.path.exists(ntpconf))
コード例 #2
0
 def test_ntp_rename_ntp_conf(self):
     """When NTP_CONF exists, rename_ntp moves it."""
     ntpconf = self.tmp_path("ntp.conf", self.new_root)
     util.write_file(ntpconf, "")
     cc_ntp.rename_ntp_conf(confpath=ntpconf)
     self.assertFalse(os.path.exists(ntpconf))
     self.assertTrue(os.path.exists("{0}.dist".format(ntpconf)))
コード例 #3
0
 def test_ntp_rename_ntp_conf(self):
     """When NTP_CONF exists, rename_ntp moves it."""
     ntpconf = self.tmp_path("ntp.conf", self.new_root)
     util.write_file(ntpconf, "")
     with mock.patch("cloudinit.config.cc_ntp.NTP_CONF", ntpconf):
         cc_ntp.rename_ntp_conf()
     self.assertFalse(os.path.exists(ntpconf))
     self.assertTrue(os.path.exists("{0}.dist".format(ntpconf)))
コード例 #4
0
 def test_ntp_rename_ntp_conf_skip_missing(self):
     """When NTP_CONF doesn't exist rename_ntp doesn't create a file."""
     ntpconf = self.tmp_path("ntp.conf", self.new_root)
     self.assertFalse(os.path.exists(ntpconf))
     with mock.patch("cloudinit.config.cc_ntp.NTP_CONF", ntpconf):
         cc_ntp.rename_ntp_conf()
     self.assertFalse(os.path.exists("{0}.dist".format(ntpconf)))
     self.assertFalse(os.path.exists(ntpconf))
コード例 #5
0
    def test_ntp_rename_ntp_conf_skip_missing(self):
        with mock.patch.object(os.path, 'exists',
                               return_value=False) as mockpath:
            with mock.patch.object(util, 'rename') as mockrename:
                cc_ntp.rename_ntp_conf()

        mockpath.assert_called_with('/etc/ntp.conf')
        mockrename.assert_not_called()
コード例 #6
0
    def test_ntp_rename_ntp_conf(self):
        with mock.patch.object(os.path, 'exists',
                               return_value=True) as mockpath:
            with mock.patch.object(util, 'rename') as mockrename:
                cc_ntp.rename_ntp_conf()

        mockpath.assert_called_with('/etc/ntp.conf')
        mockrename.assert_called_with('/etc/ntp.conf', '/etc/ntp.conf.dist')
コード例 #7
0
    def test_ntp_rename_ntp_conf_skip_missing(self):
        with mock.patch.object(os.path, 'exists',
                               return_value=False) as mockpath:
            with mock.patch.object(util, 'rename') as mockrename:
                cc_ntp.rename_ntp_conf()

        mockpath.assert_called_with('/etc/ntp.conf')
        mockrename.assert_not_called()
コード例 #8
0
    def test_ntp_rename_ntp_conf(self):
        with mock.patch.object(os.path, 'exists',
                               return_value=True) as mockpath:
            with mock.patch.object(util, 'rename') as mockrename:
                cc_ntp.rename_ntp_conf()

        mockpath.assert_called_with('/etc/ntp.conf')
        mockrename.assert_called_with('/etc/ntp.conf', '/etc/ntp.conf.dist')