예제 #1
0
    def test_WHEN_validation_of_every_assertion_part_is_successful_THEN_validation_SHOULD_succeed(self):
        # ARRANGE #
        cases = [
            NameAndValue(
                'empty list of assertion_parts',
                sut.SequenceOfCooperativeAssertionParts([])
            ),
            NameAndValue(
                'validation of every assertion_part is successful',
                sut.SequenceOfCooperativeAssertionParts([PartForValidation(SdvValidatorThat()),
                                                         PartForValidation(SdvValidatorThat())])
            ),
        ]
        validation_environment = self.environment.path_resolving_environment_pre_or_post_sds
        for case in cases:
            with self.subTest(case=case.name):
                sequence_part = case.value
                with self.subTest(name='pre sds validation'):
                    # ACT #
                    actual = sequence_part.validator.validate_pre_sds_if_applicable(validation_environment)
                    # ASSERT #
                    self.assertIsNone(actual)

                with self.subTest(name='post setup validation'):
                    # ACT #
                    actual = sequence_part.validator.validate_post_sds_if_applicable(validation_environment)
                    # ASSERT #
                    self.assertIsNone(actual)
예제 #2
0
 def test_WHEN_single_successful_assertion_part_THEN_that_assertion_part_should_have_been_executed(self):
     # ARRANGE #
     assertion_part = sut.SequenceOfCooperativeAssertionParts([SuccessfulPartThatReturnsConstructorArgPlusOne()])
     # ACT #
     actual = assertion_part.check(self.environment, self.the_os_services, 0)
     # ASSERT #
     self.assertEqual(1,
                      actual,
                      'one assertion_part should have been executed')
예제 #3
0
 def test_WHEN_a_validator_fails_pre_sds_THEN_validation_SHOULD_fail_pre_sds(self):
     # ARRANGE #
     the_error_message = 'the error message'
     assertion_part_with_successful_validation = PartForValidation(SdvValidatorThat())
     assertion_part_with_unsuccessful_validation = PartForValidation(SdvValidatorThat(
         pre_sds_return_value=asrt_text_doc.new_single_string_text_for_test(the_error_message))
     )
     sequence_checker = sut.SequenceOfCooperativeAssertionParts([assertion_part_with_successful_validation,
                                                                 assertion_part_with_unsuccessful_validation])
     validation_environment = self.environment.path_resolving_environment_pre_or_post_sds
     # ACT #
     actual = sequence_checker.validator.validate_pre_sds_if_applicable(validation_environment)
     # ASSERT #
     asrt_text_doc.is_string_for_test_that_equals(the_error_message).apply_without_message(
         self,
         actual,
     )
예제 #4
0
 def test_WHEN_a_failing_assertion_part_SHOULD_stop_execution_and_report_the_failure(self):
     # ARRANGE #
     assertion_part = sut.SequenceOfCooperativeAssertionParts([
         SuccessfulPartThatReturnsConstructorArgPlusOne(),
         PartThatRaisesFailureExceptionIfArgumentIsEqualToOne(),
         SuccessfulPartThatReturnsConstructorArgPlusOne(),
     ])
     # ACT & ASSERT #
     with self.assertRaises(pfh_exception.PfhFailException) as cm:
         assertion_part.check(self.environment, self.the_os_services, 0)
     assertion = asrt_text_doc.is_single_pre_formatted_text_that_equals(
         PartThatRaisesFailureExceptionIfArgumentIsEqualToOne.ERROR_MESSAGE
     )
     assertion.apply_with_message(
         self,
         cm.exception.err_msg,
         'error message from failing assertion_part should appear in PFH exception'
     )
예제 #5
0
 def test_WHEN_list_of_assertion_parts_is_empty_THEN_no_exception_SHOULD_be_raised(self):
     # ARRANGE #
     assertion_part = sut.SequenceOfCooperativeAssertionParts([])
     # ACT & ASSERT #
     assertion_part.check(self.environment, self.the_os_services, 'arg that is not used')