def test_action(what_to_do: int, message: str):
    if what_to_do == DO_HARD_ERROR:
        raise sut.PfhHardErrorException(asrt_text_doc.new_single_string_text_for_test(message))
    if what_to_do == DO_FAIL:
        raise sut.PfhFailException(asrt_text_doc.new_single_string_text_for_test(message))
    if what_to_do != DO_SUCCESS:
        raise ValueError('unexpected what_to_do: ' + str(what_to_do))
예제 #2
0
    def check(self, environment: InstructionEnvironmentForPostSdsStep,
              os_services: OsServices,
              files_source: FilesSource) -> FilesSource:

        path_to_check = (files_source.path_of_dir.resolve(
            environment.symbols).value_of_any_dependency__d(environment.tcds))

        helper = resolving_helper_for_instruction_env(os_services, environment)
        model_constructor = self._resolve_model_constructor(
            os_services, environment)
        model = self._get_model(model_constructor, path_to_check)

        matcher = helper.resolve_matcher(self._files_matcher)
        try:
            result = matcher.matches_w_trace(model)
            if not result.value:
                final_result = self._final_result_of(model_constructor, result)
                raise pfh_ex_method.PfhFailException(
                    rend_comb.SequenceR([
                        path_err_msgs.line_header_block__primitive(
                            file_or_dir_contents_headers.
                            unexpected_of_file_type(FileType.DIRECTORY),
                            path_to_check.describer,
                        ),
                        rendering__node_bool.BoolTraceRenderer(
                            final_result.trace),
                    ]))

            return files_source
        except HardErrorException as ex:
            raise pfh_ex_method.PfhHardErrorException(ex.error)
예제 #3
0
 def check(self,
           environment: InstructionEnvironmentForPostSdsStep,
           os_services: OsServices,
           arg: int):
     if arg == 1:
         raise pfh_exception.PfhFailException(asrt_text_doc.new_single_string_text_for_test(self.ERROR_MESSAGE))
     else:
         return arg + 1
    def _check(self, environment: InstructionEnvironmentForPostSdsStep,
               os_services: OsServices, model: StringSource):
        resolver = resolving_helper_for_instruction_env(
            os_services, environment)
        string_matcher = resolver.resolve_matcher(self._string_matcher)

        matching_result = self._apply_matcher(string_matcher, model)

        if not matching_result.value:
            raise pfh_exception.PfhFailException(
                rend_comb.SingletonSequenceR(
                    rendering__node_bool.BoolTraceRenderer(
                        matching_result.trace)))