Ejemplo n.º 1
0
    def _apply(self,
               put: unittest.TestCase,
               value: SetupSettingsHandler,
               message_builder: MessageBuilder,
               ):
        settings_builder_model = asrt_settings_builder.SettingsBuilderAssertionModel(
            value.builder,
            self.ENVIRONMENT,
            self.OS_SERVICES,
        )

        self._settings_builder.apply(
            put,
            settings_builder_model,
            message_builder.for_sub_component('settings builder'),
        )

        aei_model = AdvWvAssertionModel(
            ApplicationEnvironment(self.OS_SERVICES,
                                   self.ENVIRONMENT.proc_exe_settings,
                                   self.ENVIRONMENT.tmp_dir__path_access.paths_access,
                                   self.ENVIRONMENT.mem_buff_size,
                                   ),
            value.as_atc_execution_input(),
        )

        self._atc_exe_input.apply(
            put,
            aei_model,
            message_builder.for_sub_component('act execution info'),
        )
Ejemplo n.º 2
0
    def _check_with_sds(
            self, ddv: FullDepsDdv[PRIMITIVE],
            message_builder__ddv: MessageBuilder) -> _ValueAssertionApplier:
        self._check_validation_post_sds(ddv, message_builder__ddv)

        full_resolving_env = FullResolvingEnvironment(
            self.arrangement.symbols,
            self.tcds,
            ApplicationEnvironment(
                self.arrangement.process_execution.os_services,
                self.arrangement.process_execution.process_execution_settings,
                tmp_file_spaces.tmp_dir_file_space_for_test(
                    self.tcds.sds.internal_tmp_dir / 'application-tmp-dir'),
                self.arrangement.mem_buff_size,
            ),
        )

        message_builder__adv = self.message_builder.for_sub_component('adv')
        adv = self._resolve_adv(ddv, message_builder__adv)
        self._check_adv(adv, full_resolving_env, message_builder__adv)

        primitive = self._resolve_primitive_value(
            adv, full_resolving_env.application_environment)

        return self._check_primitive(
            primitive, full_resolving_env,
            self.message_builder.for_sub_component('primitive'))
Ejemplo n.º 3
0
 def of(self, environ: Optional[Mapping[str,
                                        str]]) -> ApplicationEnvironment:
     return ApplicationEnvironment(
         self._os_services,
         self._proc_exe_settings(environ),
         self._environment.tmp_dir__path_access.paths_access,
         self._environment.mem_buff_size,
     )
Ejemplo n.º 4
0
 def _app_env_for_execute(self) -> ApplicationEnvironment:
     env = self.environment_for_other_steps
     return ApplicationEnvironment(
         self.os_services,
         env.proc_exe_settings,
         env.tmp_dir__path_access.paths_access,
         env.mem_buff_size,
     )
Ejemplo n.º 5
0
def application_environment_for_test(
    tmp_file_space: DirFileSpace = DirFileSpaceThatMustNoBeUsed(),
    os_services_: OsServices = os_services_access.new_for_current_os(),
    process_execution_settings:
    ProcessExecutionSettings = ProcessExecutionSettings.null(),
    mem_buff_size: int = 2**10,
) -> ApplicationEnvironment:
    return ApplicationEnvironment(os_services_, process_execution_settings,
                                  tmp_file_space, mem_buff_size)
Ejemplo n.º 6
0
 def _app_env(
     self,
     environment: InstructionEnvironmentForPostSdsStep,
     settings: ProcessExecutionSettings,
 ) -> ApplicationEnvironment:
     return ApplicationEnvironment(
         self._os_services,
         settings,
         environment.tmp_dir__path_access.paths_access,
         environment.mem_buff_size,
     )
Ejemplo n.º 7
0
def resolving_env_w_custom_dir_space(
    sds: SandboxDs,
    mem_buff_size: int = 2**10,
) -> FullResolvingEnvironment:
    return FullResolvingEnvironment(
        SymbolTable.empty(), fake_tcds(),
        ApplicationEnvironment(
            OsServicesThatRaises(),
            proc_exe_env_for_test(),
            tmp_file_spaces.tmp_dir_file_space_for_test(
                sds.internal_tmp_dir / 'string-model-dir-for-test'),
            mem_buff_size,
        ))
Ejemplo n.º 8
0
def full_resolving_env_for_instruction_env(
    os_services: OsServices,
    environment: InstructionEnvironmentForPostSdsStep,
) -> FullResolvingEnvironment:
    return FullResolvingEnvironment(
        environment.symbols,
        environment.tcds,
        ApplicationEnvironment(
            os_services,
            environment.proc_exe_settings,
            environment.tmp_dir__path_access.paths_access,
            environment.mem_buff_size,
        ),
    )
Ejemplo n.º 9
0
 def _app_env(self,
              dir_space_dir: pathlib.Path,
              path_name_prefix: str,
              ) -> ApplicationEnvironment:
     dir_file_space__matcher = TmpFileSpaceThatAllowsSinglePathGeneration(
         self,
         dir_space_dir,
         path_name_prefix,
     )
     return ApplicationEnvironment(
         self.proc_exe_arr.os_services,
         self.proc_exe_arr.process_execution_settings,
         dir_file_space__matcher,
         2 ** 10,
     )
Ejemplo n.º 10
0
def resolving_helper(
    symbols: Optional[SymbolTable] = None,
    tcds: TestCaseDs = fake_tcds(),
    file_space: DirFileSpace = DirFileSpaceThatMustNoBeUsed(),
    os_services_: OsServices = os_services_access.new_for_current_os(),
    process_execution_settings:
    ProcessExecutionSettings = ProcessExecutionSettings.null(),
    mem_buff_size: int = 2**10,
) -> LogicTypeResolvingHelper:
    return LogicTypeResolvingHelper(
        (symbols if symbols is not None else empty_symbol_table()),
        tcds,
        ApplicationEnvironment(os_services_, process_execution_settings,
                               file_space, mem_buff_size),
    )
Ejemplo n.º 11
0
 def main(
     self,
     environment: InstructionEnvironmentForPostSdsStep,
     settings: InstructionSettings,
     os_services: OsServices,
 ) -> Optional[TextRenderer]:
     destination = (self._path_to_create.resolve(
         environment.symbols).value_of_any_dependency__d(environment.tcds))
     app_env = ApplicationEnvironment(
         os_services, environment.proc_exe_settings,
         environment.tmp_dir__path_access.paths_access,
         environment.mem_buff_size)
     file_maker = (self._file_maker.resolve(
         environment.symbols).value_of_any_dependency(
             environment.tcds).primitive(app_env))
     return file_maker.make__translate_hard_error(destination)
    def _apply(
        self,
        put: unittest.TestCase,
        value: SettingsBuilderAssertionModel,
        message_builder: MessageBuilder,
    ):
        component = self._component_getter(value.actual)

        app_env = ApplicationEnvironment(
            value.os_services,
            value.environment.proc_exe_settings,
            value.environment.tmp_dir__path_access.paths_access,
            value.environment.mem_buff_size,
        )
        component_model = (None if component is None else AdvWvAssertionModel(
            app_env, component))

        self._component.apply(put, component_model,
                              message_builder.for_sub_component(self._name))
Ejemplo n.º 13
0
    def _execute(self,
                 os_services: OsServices,
                 environment: InstructionEnvironmentForPostSdsStep,
                 model_getter_ddv: ModelGetterDdv[MODEL],
                 matcher_ddv: MatcherDdv[MODEL],
                 ) -> pfh.PassOrFailOrHardError:
        tcds = environment.tcds
        app_env = ApplicationEnvironment(os_services,
                                         environment.proc_exe_settings,
                                         environment.tmp_dir__path_access.paths_access,
                                         environment.mem_buff_size)
        model_getter = model_getter_ddv.value_of_any_dependency(tcds).primitive(app_env)
        matcher = matcher_ddv.value_of_any_dependency(tcds).primitive(app_env)
        model = model_getter.get()
        result = matcher.matches_w_trace(model)

        if result.value:
            return pfh.new_pfh_pass()
        else:
            return pfh.new_pfh_fail(self._failure_message(model_getter, model, result))