def on_delete_preset_clicked(self, _): """Delete a preset from the file system.""" accept = Gtk.ResponseType.ACCEPT if len(custom_mapping) > 0 and self.show_confirm_delete() != accept: return custom_mapping.changed = False delete_preset(self.selected_device, self.selected_preset) self.populate_presets()
def test_delete_preset(self): create_preset('device 1') create_preset('device 1') self.assertTrue(os.path.exists(f'{PRESETS}/device 1/new preset.json')) delete_preset('device 1', 'new preset') self.assertFalse(os.path.exists(f'{PRESETS}/device 1/new preset.json')) self.assertTrue(os.path.exists(f'{PRESETS}/device 1')) delete_preset('device 1', 'new preset 2') self.assertFalse(os.path.exists(f'{PRESETS}/device 1/new preset.json')) self.assertFalse( os.path.exists(f'{PRESETS}/device 1/new preset 2.json')) # if no preset in the directory, remove the directory self.assertFalse(os.path.exists(f'{PRESETS}/device 1'))
def on_delete_preset_clicked(self, _): """Delete a preset from the file system.""" delete_preset(self.selected_device, self.selected_preset) self.populate_presets()