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))
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)))
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)))
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))
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()
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')