def test_remove_directory(self): """Test file_host.remove_directory.""" result = untrusted_runner_pb2.RemoveDirectoryResponse(result=True) self.mock.stub().RemoveDirectory.return_value = result self.assertTrue(file_host.remove_directory('/path', True)) result = untrusted_runner_pb2.RemoveDirectoryResponse(result=False) self.mock.stub().RemoveDirectory.return_value = result self.assertFalse(file_host.remove_directory('/path', True))
def test_remove_directory(self): """Tests remote remove_directory.""" path = os.path.join(self.tmp_dir, 'dir1') os.mkdir(path) self.assertTrue(file_host.remove_directory(path)) self.assertFalse(os.path.exists(path)) os.mkdir(path) file_path = os.path.join(path, 'file') with open(file_path, 'w') as f: f.write('output') self.assertTrue(file_host.remove_directory(path, recreate=True)) self.assertTrue(os.path.isdir(path)) self.assertFalse(os.path.exists(file_path))