def _run_task(self): apex = "" apex_path = self.options.get("path") if apex_path: if not in_directory(apex_path, self.project_config.repo_root): raise TaskOptionsError( "Please specify a path inside your project repository. " "You specified: {}".format(apex_path) ) self.logger.info("Executing anonymous Apex from {}".format(apex_path)) try: with open(apex_path, "r", encoding="utf-8") as f: apex = f.read() except IOError: raise TaskOptionsError( "Could not find or read file: {}".format(apex_path) ) else: self.logger.info("Executing anonymous Apex") apex_string = self.options.get("apex") if apex_string: apex = apex + "\n" + apex_string apex = self._prepare_apex(apex) result = self.tooling._call_salesforce( method="GET", url="{}executeAnonymous".format(self.tooling.base_url), params={"anonymousBody": apex}, ) self._check_result(result) self.logger.info("Anonymous Apex Success")
def _run_task(self): apex = "" apex_path = self.options.get("path") if apex_path: if not in_directory(apex_path, self.project_config.repo_root): raise TaskOptionsError( "Please specify a path inside your project repository. " "You specified: {}".format(apex_path) ) self.logger.info("Executing anonymous Apex from {}".format(apex_path)) try: with open(apex_path, "r") as f: apex = f.read() except IOError: raise TaskOptionsError( "Could not find or read file: {}".format(apex_path) ) else: self.logger.info("Executing anonymous Apex") apex_string = self.options.get("apex") if apex_string: apex = apex + "\n" + apex_string apex = self._prepare_apex(apex) result = self.tooling._call_salesforce( method="GET", url="{}executeAnonymous".format(self.tooling.base_url), params={"anonymousBody": apex}, ) self._check_result(result) self.logger.info("Anonymous Apex Success")
def test_in_directory(self): cwd = os.getcwd() self.assertTrue(utils.in_directory(".", cwd)) self.assertFalse(utils.in_directory("..", cwd))
def test_in_directory(self): cwd = os.getcwd() assert utils.in_directory(".", cwd) assert not utils.in_directory("..", cwd)