def test_calls_atomic_delete_dev_mode(self): patch_popen(self) patch_dev(self, True) path = os.path.join(self.make_dir(), factory.make_name("file")) sudo_delete_file(path) called_command = fs_module.Popen.call_args[0][0] self.assertNotIn("sudo", called_command)
def test_calls_atomic_delete(self): patch_popen(self) patch_sudo(self) patch_dev(self, False) path = os.path.join(self.make_dir(), factory.make_name('file')) sudo_delete_file(path) self.assertThat( fs_module.Popen, MockCalledOnceWith([ 'sudo', '-n', get_library_script_path("maas-delete-file"), path ]))
def _delete_config(server): """Delete the server config.""" if os.path.exists(server.config_filename): sudo_delete_file(server.config_filename)
def test_can_delete_file_in_development(self): filename = get_maas_data_path("dhcpd.conf") with open(filename, "wb") as fd: fd.write(factory.make_bytes()) sudo_delete_file(filename) self.assertThat(filename, Not(FileExists()))