def runTest(self): # ARRANGE # source_file = fs.File.empty('source-file.src') a_dir = fs.Dir.empty('a-dir') interpreter_with_program_that_is_a_dir = command_sdvs.for_executable_file( path_sdvs.constant( path_ddvs.rel_hds(relativity_configurations.INTERPRETER_FILE.relativity_option_rel_hds, path_ddvs.constant_path_part(a_dir.name))), ) command_line = source_file arrangement = arrangement_w_tcds( hds_contents=hds_populators.multiple([ relativity_configurations.ATC_FILE.populator_for_relativity_option_root__hds( fs.DirContents([source_file]) ), relativity_configurations.INTERPRETER_FILE.populator_for_relativity_option_root__hds( fs.DirContents([a_dir]) ), ]) ) expectation = Expectation( validation=ValidationExpectationSvh.fails__pre_sds() ) # ACT & ASSERT # check_execution(self, sut.actor(interpreter_with_program_that_is_a_dir), [instr([command_line.name])], arrangement, expectation)
def __init__( self, validation: ValidationExpectationSvh = ValidationExpectationSvh.passes( ), main_result: Assertion[ sh.SuccessOrHardError] = sh_assertions.is_success(), symbols_after_parse: Assertion[ Sequence[SymbolUsage]] = asrt.is_empty_sequence, main_side_effects_on_sds: Assertion[SandboxDs] = asrt.anything_goes(), main_side_effects_on_tcds: Assertion[TestCaseDs] = asrt.anything_goes( ), settings_builder: Assertion[ SettingsBuilderAssertionModel] = asrt_settings. stdin_is_not_present(), symbols_after_main: Assertion[ Sequence[SymbolUsage]] = asrt.anything_goes(), proc_exe_settings: Assertion[ProcessExecutionSettings] = asrt. is_instance(ProcessExecutionSettings), instruction_settings: Assertion[InstructionSettings] = asrt. is_instance(InstructionSettings), ): self.validation = validation self.main_result = main_result self.settings_builder = settings_builder self.main_side_effects_on_sds = main_side_effects_on_sds self.main_side_effects_on_tcds = main_side_effects_on_tcds self.symbols_after_parse = symbols_after_parse self.symbols_after_main = symbols_after_main self.proc_exe_settings = proc_exe_settings self.instruction_settings = instruction_settings
def runTest(self): # ARRANGE # source_file = fs.File.empty('source-file.src') interpreter_with_non_existing_program_file = command_sdvs.for_executable_file( path_sdvs.constant( path_ddvs.rel_hds(relativity_configurations.INTERPRETER_FILE.relativity_option_rel_hds, path_ddvs.constant_path_part('non-existing'))), ) arrangement = arrangement_w_tcds( hds_contents=relativity_configurations.ATC_FILE.populator_for_relativity_option_root__hds( fs.DirContents([source_file]) ) ) expectation = Expectation( validation=ValidationExpectationSvh.fails__pre_sds() ) # ACT & ASSERT # check_execution(self, sut.actor(interpreter_with_non_existing_program_file), [instr([source_file.name])], arrangement, expectation)
def test_executable_file_must_exist(self): act_phase_instructions = [instr(['non-existing-executable'])] arrangement = arrangement_w_tcds() expectation = Expectation( validation=ValidationExpectationSvh.fails__pre_sds()) check_execution(self, sut.actor(), act_phase_instructions, arrangement, expectation)
def test_referenced_file_does_not_exist__rel_hds(self): rel_conf = rel_opt_conf.conf_rel_any(RelOptionType.REL_HDS_CASE) syntax = InstructionAbsStx( StringSourceOfFileAbsStx( rel_conf.path_abs_stx_of_name('non-existing-file'))) CHECKER.check_multi_source__abs_stx( self, syntax, Arrangement(), MultiSourceExpectation( validation=ValidationExpectationSvh.fails__pre_sds(), ))
def runTest(self): command_line = 'non-existing-file.src' arrangement = arrangement_w_tcds() expectation = Expectation( validation=ValidationExpectationSvh.fails__pre_sds() ) self._check(command_line, arrangement, expectation)
def test_executable_file_must_be_executable(self): executable_file_name = 'existing-executable' act_phase_instructions = [instr([executable_file_name])] arrangement = arrangement_w_tcds( hds_contents=relativity_configurations.ATC_FILE. populator_for_relativity_option_root__hds( fs.DirContents([File.empty(executable_file_name)]))) expectation = Expectation( validation=ValidationExpectationSvh.fails__pre_sds()) check_execution(self, sut.actor(), act_phase_instructions, arrangement, expectation)
def runTest(self): actor = sut.actor(_command_for_non_existing_interpreter()) empty_source = [] check_execution(self, actor, empty_source, arrangement_w_tcds(), Expectation( validation=ValidationExpectationSvh.fails__pre_sds() ) )
def expectation_that_file_for_expected_contents_is_invalid( conf: RelativityOptionConfiguration) -> Expectation: if conf.exists_pre_sds: return expectation( validation=ValidationExpectationSvh.fails__pre_sds(), symbol_usages=conf.symbols.usages_expectation(), ) else: return expectation( main_result=pfh_assertions.is_hard_error__with_arbitrary_message(), symbol_usages=conf.symbols.usages_expectation(), )
def runTest(self): source_file = 'source-file.src' command_line = source_file arrangement = arrangement_w_tcds( hds_contents=contents_in(RelHdsOptionType.REL_HDS_ACT, fs.DirContents([ Dir.empty(source_file)])) ) expectation = Expectation( validation=ValidationExpectationSvh.fails__pre_sds() ) self._check(command_line, arrangement, expectation)
def test_referenced_file_is_a_directory__pre_sds(self): the_dir = Dir.empty('a-directory') rel_conf = rel_opt_conf.conf_rel_any(RelOptionType.REL_HDS_CASE) syntax = InstructionAbsStx( StringSourceOfFileAbsStx( rel_conf.path_abs_stx_of_name(the_dir.name))) CHECKER.check_multi_source__abs_stx( self, syntax, Arrangement( tcds_contents=rel_conf.populator_for_relativity_option_root( DirContents([the_dir])), ), MultiSourceExpectation( validation=ValidationExpectationSvh.fails__pre_sds(), ), )
def runTest(self): # ARRANGE # source_w_relative_name_of_existing_file = args.interpret_py_source_file( 'program.py') # ACT & ASSERT # integration_check.check_execution( self, sut.actor(), [ instr( source_w_relative_name_of_existing_file.as_arguments.lines) ], arrangement_w_tcds(), Expectation(validation=ValidationExpectationSvh.fails__pre_sds()), )
def expectation( validation: ValidationExpectationSvh = ValidationExpectationSvh.passes(), main_result: Assertion[pfh.PassOrFailOrHardError] = pfh_assertions.is_pass(), symbol_usages: Assertion[Sequence[SymbolUsage]] = asrt.is_empty_sequence, main_side_effects_on_sds: Assertion[SandboxDs] = asrt.anything_goes(), main_side_effects_on_tcds: Assertion[TestCaseDs] = asrt.anything_goes(), source: Assertion[ParseSource] = asrt.anything_goes(), instruction_settings: Assertion[InstructionSettings] = asrt.is_instance(InstructionSettings) ) -> Expectation: return Expectation( validation_pre_sds=validation.pre_sds, validation_post_sds=validation.post_sds, main_result=main_result, symbol_usages=symbol_usages, main_side_effects_on_sds=main_side_effects_on_sds, main_side_effects_on_tcds=main_side_effects_on_tcds, instruction_settings=instruction_settings, source=source, )
def __init__( self, pre_validation_result: Assertion[ svh. SuccessOrValidationErrorOrHardError] = svh_assertions.is_success(), main_result: Assertion[ sh.SuccessOrHardError] = sh_assertions.is_success(), post_validation_result: Assertion[ svh. SuccessOrValidationErrorOrHardError] = svh_assertions.is_success(), symbol_usages: Assertion[ Sequence[SymbolUsage]] = asrt.is_empty_sequence, main_side_effects_on_sds: Assertion[SandboxDs] = asrt.anything_goes(), main_side_effects_on_tcds: Assertion[TestCaseDs] = asrt.anything_goes( ), settings_builder: Assertion[ SettingsBuilderAssertionModel] = asrt_settings. stdin_is_not_present(), source: Assertion[ParseSource] = asrt.anything_goes(), symbols_after_main: Assertion[ Sequence[SymbolUsage]] = asrt.anything_goes(), proc_exe_settings: Assertion[ProcessExecutionSettings] = asrt. is_instance(ProcessExecutionSettings), instruction_settings: Assertion[InstructionSettings] = asrt. is_instance(InstructionSettings)): super().__init__( ValidationExpectationSvh(pre_validation_result, post_validation_result), main_result, symbol_usages, main_side_effects_on_sds, main_side_effects_on_tcds, settings_builder, symbols_after_main, proc_exe_settings, instruction_settings, ) self.source = source self.pre_validation_result = pre_validation_result self.post_validation_result = post_validation_result
def expectation__svh(self) -> ValidationExpectationSvh: return ValidationExpectationSvh.corresponding_to(self.actual)
from exactly_lib.tcfs.path_relativity import RelOptionType from exactly_lib_test.type_val_deps.test_resources.validation.svh_validation import ValidationExpectationSvh class ValidationCase: def __init__(self, name: str, path_relativity: RelOptionType, expectation: ValidationExpectationSvh, ): self.name = name self.path_relativity = path_relativity self.expectation = expectation VALIDATION_CASES = [ ValidationCase( 'pre sds', RelOptionType.REL_HDS_CASE, ValidationExpectationSvh.fails__pre_sds(), ), ValidationCase( 'post sds', RelOptionType.REL_ACT, ValidationExpectationSvh.hard_error__post_sds(), ), ]
def expectation__svh(self) -> ValidationExpectationSvh: return ValidationExpectationSvh.of_plain( self._string_transformer_case.expectation__bool)