def runTest(self): # ARRANGE # dst_path = DefaultRelPathAbsStx('non-existing-dir') for modification in fs_abs_stx.ModificationType: for validation_case in validation_cases.failing_validation_cases(): instruction_syntax = NewDirArguments( dst_path, fs_abs_stx.DirContentsExplicitAbsStx(modification, validation_case.value.syntax), ) # ACT & ASSERT # _CHECKER.check__abs_stx__std_layouts_and_source_variants( self, instruction_syntax, embryo_arr_exp.Arrangement.phase_agnostic( symbols=validation_case.value.symbol_context.symbol_table, ), embryo_arr_exp.MultiSourceExpectation.phase_agnostic( validation=validation_case.value.assertion, symbol_usages=validation_case.value.symbol_context.usages_assertion, ), sub_test_identifiers={ 'modification': modification, 'validation': validation_case.name }, )
def runTest(self): sub_dir = fs.Dir.empty('sub-dir') top_dir = fs.Dir('top-dir', [sub_dir]) for rel_conf in RELATIVITY_OPTIONS: dst_path = rel_conf.path_abs_stx_of_name__c( [top_dir.name, sub_dir.name]) instruction_syntax = NewDirArguments.implicitly_empty(dst_path) with self.subTest(relativity=rel_conf.name): # ACT & ASSERT # _CHECKER.check__abs_stx( self, instruction_syntax, embryo_arr_exp.Arrangement.phase_agnostic( symbols=rel_conf.symbols.in_arrangement(), tcds=TcdsArrangement( pre_population_action= SETUP_CWD_TO_NON_TCDS_DIR_ACTION)), embryo_arr_exp.Expectation.phase_agnostic_3( symbol_usages=rel_conf.symbols.usages_expectation(), main_result=is_success(), main_side_effects_on_files=TcdsExpectation( sds=rel_conf.assert_root_dir_contains_exactly__p( [top_dir]))), )
def _test_relativity( self, rel_opt_conf: RelativityOptionConfigurationForRelNonHds, ): # ARRANGE # dst_path = rel_opt_conf.path_abs_stx_of_name('non-existing-file') for modification in fs_abs_stx.ModificationType: for validation_case in validation_cases.failing_validation_cases(): instruction_syntax = NewDirArguments( dst_path, fs_abs_stx.DirContentsExplicitAbsStx( modification, validation_case.value.syntax), ) all_symbols = rel_opt_conf.symbols.contexts_for_arrangement( ) + [validation_case.value.symbol_context] # ACT & ASSERT self.conf.instruction_checker.check_parsing__abs_stx__const( self, self.conf.parser(), instruction_syntax, self.conf.arrangement( symbols=SymbolContext.symbol_table_of_contexts( all_symbols), ), self.conf.expect_failing_validation( validation_case.value.actual, symbol_usages=SymbolContext. usages_assertion_of_contexts(all_symbols), ))
def runTest(self): # ARRANGE # non_existing_leaf = fs.Dir.empty('leaf-dir') existing_top_dir__name = 'top-dir' for rel_conf in RELATIVITY_OPTIONS: dst_path = rel_conf.path_abs_stx_of_name__c( [existing_top_dir__name, non_existing_leaf.name]) instruction_syntax = NewDirArguments.implicitly_empty(dst_path) # ACT & ASSERT # with self.subTest(relativity=rel_conf.name): _CHECKER.check__abs_stx( self, instruction_syntax, embryo_arr_exp.Arrangement.phase_agnostic( symbols=rel_conf.symbols.in_arrangement(), tcds=TcdsArrangement( pre_population_action= SETUP_CWD_TO_NON_TCDS_DIR_ACTION, tcds_contents=rel_conf. populator_for_relativity_option_root__s( [fs.Dir.empty(existing_top_dir__name)]), )), embryo_arr_exp.Expectation.phase_agnostic_3( symbol_usages=rel_conf.symbols.usages_expectation(), main_result=is_success(), main_side_effects_on_files=TcdsExpectation( sds=rel_conf.assert_root_dir_contains_exactly__p([ fs.Dir(existing_top_dir__name, [non_existing_leaf]) ]))), )
def test_invalid_path(self): # ARRANGE # existing_file = fs.File.empty('existing-file') existing_dir_with_file = fs.Dir('existing-dir', [existing_file]) path_cases: Sequence[NInpArr[ FileNameComponents, FileSystemElement]] = [ NInpArr( 'file (direct)', [existing_file.name], existing_file, ), NInpArr( 'file in dir', [existing_dir_with_file.name, existing_file.name], existing_dir_with_file, ), NInpArr( 'middle component is regular file', [existing_file.name, 'non-existing'], existing_file, ), ] for path_case in path_cases: for rel_conf in RELATIVITY_OPTIONS: syntax_of_existing_file = NewDirArguments.implicitly_empty( rel_conf.path_abs_stx_of_name__c(path_case.input)) with self.subTest(relativity=rel_conf.name, path=path_case.name): # ACT & ASSERT # _CHECKER.check__abs_stx__std_layouts_and_source_variants( self, syntax_of_existing_file, embryo_arr_exp.Arrangement.phase_agnostic( symbols=rel_conf.symbols.in_arrangement(), tcds=TcdsArrangement( pre_population_action= SETUP_CWD_TO_NON_TCDS_DIR_ACTION, tcds_contents=rel_conf. populator_for_relativity_option_root__s( [path_case.arrangement]))), embryo_arr_exp.MultiSourceExpectation.phase_agnostic_2( symbol_usages=rel_conf.symbols.usages_expectation( ), main_result=is_failure(), ), sub_test_identifiers={ 'relativity': rel_conf.name, 'path': path_case.name })
def _test_relativity( self, rel_opt_conf: RelativityOptionConfigurationForRelNonHds, ): existing_regular_file = fs.File.empty('a-regular-file') instruction_syntax = NewDirArguments.implicitly_empty( rel_opt_conf.path_abs_stx_of_name(existing_regular_file.name)) self.conf.instruction_checker.check_parsing__abs_stx__const( self, self.conf.parser(), instruction_syntax, self._arrangement_with_cwd_as_non_of_the_relativity_root_dirs( rel_opt_conf, sds_contents_before_main=rel_opt_conf. populator_for_relativity_option_root__non_hds__s( [existing_regular_file])), self.conf.expect_failure_to_create_dir( symbol_usages=rel_opt_conf.symbols.usages_expectation(), ))
def runTest(self): # ARRANGE # an_empty_dir = fs.Dir.empty('an-empty-dir') top_dir_with_sub_dir = fs.Dir('top-dir', [an_empty_dir]) path_cases: Sequence[NInpArr[FileNameComponents, FileSystemElement]] = [ NInpArr( 'direct', [an_empty_dir.name], an_empty_dir, ), NInpArr( 'dir in dir', [ top_dir_with_sub_dir.name, an_empty_dir.name ], top_dir_with_sub_dir, ), ] for path_case in path_cases: for rel_conf in RELATIVITY_OPTIONS: dst_path = rel_conf.path_abs_stx_of_name__c(path_case.input) instruction_syntax = NewDirArguments.implicitly_empty(dst_path) # ACT & ASSERT # with self.subTest(relativity=rel_conf.name, path=path_case.name): _CHECKER.check__abs_stx( self, instruction_syntax, embryo_arr_exp.Arrangement.phase_agnostic( symbols=rel_conf.symbols.in_arrangement(), tcds=TcdsArrangement( pre_population_action= SETUP_CWD_TO_NON_TCDS_DIR_ACTION, tcds_contents=rel_conf. populator_for_relativity_option_root__s( [path_case.arrangement]), )), embryo_arr_exp.Expectation.phase_agnostic_3( symbol_usages=rel_conf.symbols.usages_expectation( ), main_result=is_failure(), ), )
def _test_relativity( self, rel_opt_conf: RelativityOptionConfigurationForRelNonHds, ): top_dir__name = 'top-dir' sub_dir__name = 'sub-dir' instruction_syntax = NewDirArguments.implicitly_empty( rel_opt_conf.path_abs_stx_of_name__c([ top_dir__name, sub_dir__name, ])) self.conf.instruction_checker.check_parsing__abs_stx__const( self, self.conf.parser(), instruction_syntax, self._arrangement_with_cwd_as_non_of_the_relativity_root_dirs( rel_opt_conf), self.conf.expect_success( main_side_effects_on_sds=rel_opt_conf. assert_root_dir_contains_exactly__p( [Dir(top_dir__name, [Dir.empty(sub_dir__name)])]), symbol_usages=rel_opt_conf.symbols.usages_expectation(), ))
def runTest(self): expected_created_dir = fs.Dir.empty('dir-that-should-be-constructed') for rel_conf in RELATIVITY_OPTIONS: dst_path = rel_conf.path_abs_stx_of_name(expected_created_dir.name) instruction_syntax = NewDirArguments.implicitly_empty(dst_path) # ACT & ASSERT # _CHECKER.check__abs_stx__std_layouts_and_source_variants( self, instruction_syntax, embryo_arr_exp.Arrangement.phase_agnostic( symbols=rel_conf.symbols.in_arrangement(), tcds=TcdsArrangement( pre_population_action=SETUP_CWD_TO_NON_TCDS_DIR_ACTION) ), embryo_arr_exp.MultiSourceExpectation.phase_agnostic_2( symbol_usages=rel_conf.symbols.usages_expectation(), main_result=is_success(), main_side_effects_on_files=TcdsExpectation( sds=rel_conf.assert_root_dir_contains_exactly__p( [expected_created_dir]))), sub_test_identifiers={ 'relativity': rel_conf.name, })
def test_fail_when_superfluous_arguments(self): invalid_syntax = SequenceAbsStx.followed_by_superfluous( NewDirArguments.implicitly_empty( PathStringAbsStx.of_plain_str('valid_file_name'))) PARSE_CHECKER.check_invalid_syntax__abs_stx(self, invalid_syntax)