def test_movetotrash_file_bad(self): """Something bad happen when moving to trash, removed anyway.""" path = os.path.join(self.basedir, 'foo') open_file(path, 'w').close() move_to_trash(path) self.assertFalse(os.path.exists(path)) self.assertTrue(self.handler.check_warning("Problems moving to trash!", "Removing anyway", "foo"))
def test_movetotrash_file_ok(self): """Move a file to trash ok. Just check it was removed because can't monkeypatch the trash. to see that that was actually called. """ move_to_trash(self.testfile) self.assertFalse(path_exists(self.testfile))
def test_movetotrash_dir_ok(self): """Move a dir to trash ok. Just check it was removed because can't monkeypatch the trash to see that that was actually called. """ path = os.path.join(self.basedir, 'foo') make_dir(path) move_to_trash(path) self.assertFalse(path_exists(path))
def test_movetotrash_file_systemnotcapable(self): """The system is not capable of moving into trash.""" FakeGIOFile._bad_trash_call = GIO_NOT_SUPPORTED self.patch(gio, "File", FakeGIOFile) path = os.path.join(self.basedir, 'foo') open_file(path, 'w').close() move_to_trash(path) self.assertFalse(os.path.exists(path)) self.assertTrue(self.handler.check_warning("Problems moving to trash!", "Removing anyway", "foo", "ERROR_NOT_SUPPORTED"))
def test_movetotrash_dir_bad(self): """Something bad happen when moving to trash, removed anyway.""" FakeGIOFile._bad_trash_call = False # error self.patch(gio, "File", FakeGIOFile) path = os.path.join(self.basedir, 'foo') os.mkdir(path) open_file(os.path.join(path, 'file inside directory'), 'w').close() move_to_trash(path) self.assertFalse(os.path.exists(path)) self.assertTrue(self.handler.check_warning("Problems moving to trash!", "Removing anyway", "foo"))