Exemple #1
0
 def test_unsuccessful_WHEN_actual_is_not_expected(self):
     # ARRANGE #
     expected_err_msg = 'expected error message'
     actual_err_msg = 'actual error message'
     cases = [
         NEA(
             'VALIDATION - SUCCESS/any error message',
             sut.status_is_not_success(
                 svh.SuccessOrValidationErrorOrHardErrorEnum.
                 VALIDATION_ERROR),
             svh.new_svh_success(),
         ),
         NEA(
             'VALIDATION - VALIDATION/non-matching error message',
             sut.status_is_not_success(
                 svh.SuccessOrValidationErrorOrHardErrorEnum.
                 VALIDATION_ERROR,
                 asrt_text_doc.is_single_pre_formatted_text_that_equals(
                     expected_err_msg)),
             svh.new_svh_validation_error(_renderer_of_str(actual_err_msg)),
         ),
         NEA(
             'VALIDATION - VALIDATION/non-matching error message/const msg',
             sut.status_is_not_success(
                 svh.SuccessOrValidationErrorOrHardErrorEnum.
                 VALIDATION_ERROR,
                 asrt_text_doc.is_single_pre_formatted_text_that_equals(
                     expected_err_msg)),
             svh.new_svh_validation_error__str(actual_err_msg),
         ),
         NEA(
             'HARD_ERROR - SUCCESS/any error message',
             sut.status_is_not_success(
                 svh.SuccessOrValidationErrorOrHardErrorEnum.HARD_ERROR),
             svh.new_svh_success(),
         ),
         NEA(
             'HARD_ERROR - HARD_ERROR/non-matching error message',
             sut.status_is_not_success(
                 svh.SuccessOrValidationErrorOrHardErrorEnum.HARD_ERROR,
                 asrt_text_doc.is_single_pre_formatted_text_that_equals(
                     expected_err_msg)),
             svh.new_svh_hard_error(_renderer_of_str(actual_err_msg)),
         ),
         NEA(
             'HARD_ERROR - HARD_ERROR/non-matching error message/const msg',
             sut.status_is_not_success(
                 svh.SuccessOrValidationErrorOrHardErrorEnum.HARD_ERROR,
                 asrt_text_doc.is_single_pre_formatted_text_that_equals(
                     expected_err_msg)),
             svh.new_svh_hard_error__str(actual_err_msg),
         ),
     ]
     for case in cases:
         with self.subTest(case.name):
             # ACT & ASSERT #
             assert_that_assertion_fails(case.expected, case.actual)
Exemple #2
0
 def test_success_WHEN_actual_is_expected(self):
     # ARRANGE #
     expected_err_msg = 'expected error message'
     cases = [
         NEA(
             'VALIDATION/any error message',
             sut.status_is_not_success(
                 svh.SuccessOrValidationErrorOrHardErrorEnum.
                 VALIDATION_ERROR),
             svh.new_svh_validation_error__str(expected_err_msg),
         ),
         NEA(
             'VALIDATION/matching error message',
             sut.status_is_not_success(
                 svh.SuccessOrValidationErrorOrHardErrorEnum.
                 VALIDATION_ERROR,
                 asrt_text_doc.is_single_pre_formatted_text_that_equals(
                     expected_err_msg)),
             svh.new_svh_validation_error__str(expected_err_msg),
         ),
         NEA(
             'HARD_ERROR/any error message',
             sut.status_is_not_success(
                 svh.SuccessOrValidationErrorOrHardErrorEnum.HARD_ERROR),
             svh.new_svh_hard_error__str(expected_err_msg),
         ),
         NEA(
             'HARD_ERROR/matching error message',
             sut.status_is_not_success(
                 svh.SuccessOrValidationErrorOrHardErrorEnum.HARD_ERROR,
                 asrt_text_doc.is_single_pre_formatted_text_that_equals(
                     expected_err_msg)),
             svh.new_svh_hard_error__str(expected_err_msg),
         ),
     ]
     for case in cases:
         with self.subTest(case.name):
             # ACT & ASSERT #
             case.expected.apply_without_message(self, case.actual)
Exemple #3
0
 def runTest(self):
     conf = self.configuration
     test_case = TestCaseGeneratorWithExtraInstrsBetweenRecordingInstr() \
         .add(conf.phase,
              conf.instruction_that_returns(svh.new_svh_hard_error__str('Error message from hard error')))
     execute_test_case_with_recording(
         self, Arrangement(test_case),
         Expectation(
             asrt_result.matches2(
                 ExecutionFailureStatus.HARD_ERROR,
                 asrt_result.has_sds(),
                 asrt_result.has_no_action_to_check_outcome(),
                 ExpectedFailureForInstructionFailure.new_with_message(
                     conf.step,
                     test_case.the_extra(conf.phase)[0].source,
                     'Error message from hard error'),
             ),
             conf.expected_steps,
         ))
 def test_hard_error(self):
     test_case = _single_successful_instruction_in_each_phase()
     self._check(
         Arrangement(test_case,
                     atc_validate_pre_sds=validate_action_that_returns(
                         svh.new_svh_hard_error__str(
                             'error in act/validate-pre-sds'))),
         Expectation(
             asrt_result.matches2(
                 ExecutionFailureStatus.HARD_ERROR,
                 asrt_result.has_no_sds(),
                 asrt_result.has_no_action_to_check_outcome(),
                 ExpectedFailureForPhaseFailure.new_with_message(
                     phase_step.ACT__VALIDATE_PRE_SDS,
                     'error in act/validate-pre-sds')),
             [phase_step.ACT__PARSE] + SYMBOL_VALIDATION_STEPS__ONCE + [
                 phase_step.SETUP__VALIDATE_PRE_SDS,
                 phase_step.ACT__VALIDATE_PRE_SDS,
             ],
         ))
Exemple #5
0
 def test_execution_mode_skipped_but_failing_instruction_in_configuration_phase_after_setting_execution_mode(self):
     test_case = test_case_with_two_instructions_in_each_phase() \
         .add(phase_identifier.CONFIGURATION,
              test.ConfigurationPhaseInstructionThatSetsExecutionMode(
                  TestCaseStatus.SKIP)) \
         .add(phase_identifier.CONFIGURATION,
              test.configuration_phase_instruction_that(do_return(svh.new_svh_hard_error__str('hard error msg'))))
     self._check(
         Arrangement(test_case),
         Expectation(
             asrt_result.matches2(
                 FullExeResultStatus.HARD_ERROR,
                 asrt_result.has_no_sds(),
                 asrt_result.has_no_action_to_check_outcome(),
                 ExpectedFailureForInstructionFailure.new_with_message(
                     phase_step.CONFIGURATION__MAIN,
                     test_case.the_extra(phase_identifier.CONFIGURATION)[1].source,
                     'hard error msg')),
             [phase_step.CONFIGURATION__MAIN],
         ))
Exemple #6
0
 def test_success_WHEN_actual_is_expected(self):
     # ARRANGE #
     cases = [
         NEA(
             'SUCCESS',
             svh.SuccessOrValidationErrorOrHardErrorEnum.SUCCESS,
             svh.new_svh_success(),
         ),
         NEA(
             'VALIDATION_ERROR',
             svh.SuccessOrValidationErrorOrHardErrorEnum.VALIDATION_ERROR,
             svh.new_svh_validation_error(
                 asrt_text_doc.new_single_string_text_for_test(
                     'validation msg')),
         ),
         NEA(
             'VALIDATION_ERROR/const msg',
             svh.SuccessOrValidationErrorOrHardErrorEnum.VALIDATION_ERROR,
             svh.new_svh_validation_error__str('validation msg'),
         ),
         NEA(
             'HARD_ERROR',
             svh.SuccessOrValidationErrorOrHardErrorEnum.HARD_ERROR,
             svh.new_svh_hard_error(
                 asrt_text_doc.new_single_string_text_for_test(
                     'hard err msg')),
         ),
         NEA(
             'HARD_ERROR/const msg',
             svh.SuccessOrValidationErrorOrHardErrorEnum.HARD_ERROR,
             svh.new_svh_hard_error__str('hard err msg'),
         ),
     ]
     for case in cases:
         with self.subTest(case.name):
             assertion = sut.status_is(case.expected)
             # ACT & ASSERT #
             assertion.apply_without_message(self, case.actual)
Exemple #7
0
 def test_success_WHEN_actual_is_not_success(self):
     # ARRANGE #
     cases = [
         NameAndValue(
             'VALIDATION_ERROR',
             svh.new_svh_validation_error(
                 asrt_text_doc.new_single_string_text_for_test(
                     'failure msg'))),
         NameAndValue('VALIDATION_ERROR/const msg',
                      svh.new_svh_validation_error__str('failure msg')),
         NameAndValue(
             'HARD_ERROR',
             svh.new_svh_hard_error(
                 asrt_text_doc.new_single_string_text_for_test(
                     'hard error msg'))),
         NameAndValue('HARD_ERROR/const msg',
                      svh.new_svh_hard_error__str('hard error msg')),
     ]
     assertion = sut.is_success()
     for case in cases:
         with self.subTest(case.name):
             # ACT #
             assert_that_assertion_fails(assertion, case.value)
Exemple #8
0
    lines = output.split()
    put.assertTrue(
        len(lines) > 0,
        'There should be at least one line (found {})'.format(len(lines)))

    first_line = lines[0]

    put.assertEqual(expected_exit_value.exit_identifier, first_line,
                    'first line')


DO_RAISES_EXCEPTION = do_raise(ValueError('implementation error msg'))

SVH_VALIDATION_ERROR = do_return(
    svh.new_svh_validation_error__str('validation error msg'))
SVH_HARD_ERROR = do_return(svh.new_svh_hard_error__str('hard error msg'))

SH_HARD_ERROR = do_return(sh.new_sh_hard_error__str('hard error msg'))


def output_is_sds_which_should_be_preserved(
        sds_dir_name: str) -> Assertion[str]:
    return asrt.and_([
        IsExistingDir(sds_dir_name),
        asrt.equals(sds_dir_name + '\n'),
    ])


def output_is_empty(sds_dir_name: str) -> Assertion[str]:
    return asrt.equals('')
 def _parse(self, rest_of_line: str) -> model.Instruction:
     return configuration_phase_instruction_that(main=do_return(
         svh.new_svh_hard_error__str('unconditional hard error')))