Ejemplo n.º 1
0
    def runTest(self):
        # ARRANGE #

        files_matcher_name = 'the_files_matcher'
        checked_dir_location = RelSdsOptionType.REL_TMP
        checked_dir = Dir.empty('checked-dir')

        # ACT & ASSERT #

        integration_check.CHECKER__PARSE_FULL.check_multi__w_source_variants(
            self,
            arguments=args.DirContents(
                fsm_args.SymbolReference(files_matcher_name)).as_arguments,
            input_=integration_check.file_in_sds(checked_dir_location,
                                                 checked_dir.name),
            symbol_references=asrt.matches_singleton_sequence(
                is_reference_to_files_matcher(files_matcher_name)),
            execution=[
                NExArr(
                    'checked dir is empty',
                    PrimAndExeExpectation.of_exe(
                        main_result=asrt_matching_result.matches_value(
                            matcher_result)),
                    arrangement_w_tcds(
                        non_hds_contents=sds_populator.contents_in(
                            checked_dir_location, DirContents([checked_dir])),
                        symbols=FilesMatcherSymbolContext.
                        of_primitive_constant(files_matcher_name,
                                              matcher_result).symbol_table,
                    ),
                ) for matcher_result in [False, True]
            ],
        )
Ejemplo n.º 2
0
    def runTest(self):
        # ARRANGE #

        name_of_referenced_selector = 'SELECTOR'
        name_of_referenced_files_matcher = 'FILES_MATCHER'

        expected_symbol_usages = asrt.matches_sequence([
            is_reference_to_file_matcher(name_of_referenced_selector),
            is_reference_to_files_matcher(name_of_referenced_files_matcher),
        ])

        arguments = fsm_args.argument_constructor_for_symbol_reference(
            files_matcher_symbol_name=name_of_referenced_files_matcher,
            named_matcher=name_of_referenced_selector).apply(
                expectation_type_config__non_is_success(
                    ExpectationType.POSITIVE))

        source = remaining_source(arguments)

        # ACT #

        sdv = sut.parsers().full.parse(source)

        # ASSERT #

        expected_symbol_usages.apply_without_message(self, sdv.references)
Ejemplo n.º 3
0
 def runTest(self):
     fsm_symbol_name = 'the_files_matcher'
     integration_check.CHECKER__PARSE_FULL.check_multi__w_source_variants(
         self,
         args.DirContents(
             args.SymbolReference(fsm_symbol_name)).as_arguments,
         symbol_references=asrt.matches_singleton_sequence(
             is_reference_to_files_matcher(fsm_symbol_name)),
         input_=integration_check.constant_relative_file_name(
             'arbitrary-file-argument'),
         execution=instruction_validation_cases.
         failing_validation_cases__multi_exe(fsm_symbol_name))
Ejemplo n.º 4
0
        contents_cases = test_data.strip_file_type_info_s([
            test_data.expected_is_direct_contents_of_actual(
                case.name, case.value) for case in test_data.cases()
        ])

        # ACT & ASSERT #

        integration_check.CHECKER__PARSE_FULL.check_multi(
            self,
            arguments=args.DirContents(
                fsm_args.SymbolReference(
                    model_checker_symbol_name)).as_arguments,
            parse_expectation=ParseExpectation(
                symbol_references=asrt.matches_singleton_sequence(
                    is_reference_to_files_matcher(
                        model_checker_symbol_name)), ),
            input_=integration_check.file_in_tcds(model_location, model_name),
            execution=[
                NExArr(
                    contents_case.name,
                    PrimAndExeExpectation.of_exe(),
                    arrangement_w_tcds(
                        tcds_contents=tcds_populators.
                        TcdsPopulatorForRelOptionType(
                            model_location,
                            DirContents(
                                [Dir(model_name, contents_case.actual)])),
                        symbols=SymbolTable({
                            model_checker_symbol_name:
                            model_checker.matcher__sym_tbl_container(
                                self, model_path, contents_case.expected)
Ejemplo n.º 5
0
 def expectation(self) -> Expectation:
     return Expectation(
         ParseExpectation(symbol_references=asrt.matches_singleton_sequence(
             is_reference_to_files_matcher(self.files_matcher_name)), ),
         ExecutionExpectation(is_hard_error=asrt_matcher.is_hard_error(
             asrt.equals(self.error_message))))
Ejemplo n.º 6
0
    def runTest(self):
        # ARRANGE #
        positive_expectation = expectation_type_config__non_is_success(
            ExpectationType.POSITIVE)
        rel_opt_conf = rel_opt_confs.conf_rel_sds(RelSdsOptionType.REL_TMP)
        parser = sut.parsers().full

        # dir contents

        checked_dir = Dir('checked-dir', [
            File.empty('a.x'),
            File.empty('a.y'),
            File.empty('b.x'),
            File.empty('b.y'),
        ])

        # arguments

        file_matcher_arg__begins_with_a = fm_args.file_matcher_arguments(
            name_pattern='a*')

        file_matcher_arg__ends_with_x = fm_args.file_matcher_arguments(
            name_pattern='*.x')

        files_matcher_args__num_files_eq_1 = fsm_args.NumFilesAssertionVariant(
            int_args.int_condition(comparators.EQ, 1))

        files_matcher_args__num_files_ending_with_x_eq_1 = fsm_args.SelectionAndMatcherArgumentsConstructor(
            file_matcher_arg__ends_with_x,
            files_matcher_args__num_files_eq_1,
        )

        files_matcher_source__num_files_ending_with_x_eq_1 = files_matcher_args__num_files_ending_with_x_eq_1.apply(
            positive_expectation)

        symbol_name = 'FILES_MATCHER_SYMBOL'

        files_matcher_args__begins_with_a__symbol = fsm_args.SelectionAndMatcherArgumentsConstructor(
            file_matcher_arg__begins_with_a,
            fsm_args.symbol_reference(symbol_name),
        )
        files_matcher_source__begins_with_a__symbol = files_matcher_args__begins_with_a__symbol.apply(
            positive_expectation)

        num_files_ending_with_x_eq_1_resolver = parser.parse(
            remaining_source(
                files_matcher_source__num_files_ending_with_x_eq_1))

        symbols = FilesMatcherSymbolContext.of_sdv(
            symbol_name,
            num_files_ending_with_x_eq_1_resolver,
        ).symbol_table

        # ACT & ASSERT #

        integration_check.CHECKER__PARSE_FULL.check(
            self,
            remaining_source(files_matcher_source__begins_with_a__symbol),
            model.model_with_source_path_as_sub_dir_of_rel_root(
                checked_dir.name)(rel_opt_conf),
            arrangement_w_tcds(
                non_hds_contents=rel_opt_conf.
                populator_for_relativity_option_root__sds(
                    DirContents([checked_dir])),
                symbols=symbols,
            ),
            Expectation(
                ParseExpectation(symbol_references=asrt.matches_sequence(
                    [is_reference_to_files_matcher(symbol_name)]), ),
                ExecutionExpectation(
                    main_result=matcher_assertions.is_matching_success(), ),
            ))
Ejemplo n.º 7
0
 def expectation(self, execution: ExecutionExpectation) -> Expectation:
     return Expectation(
         ParseExpectation(symbol_references=asrt.matches_singleton_sequence(
             is_reference_to_files_matcher(self.files_matcher_name)), ),
         execution)
Ejemplo n.º 8
0
 def symbol_reference_assertion(self) -> Assertion[SymbolReference]:
     return is_reference_to_files_matcher(self.files_matcher_name)
Ejemplo n.º 9
0
 def reference_assertion(self,
                         symbol_name: str) -> Assertion[SymbolReference]:
     return is_reference_to_files_matcher(symbol_name)