Exemplo n.º 1
0
    def test_subtest_pass(self):
        test_rec = yield htf.Test(
            phase0,
            htf.Subtest(
                'subtest', phase1,
                phase_branches.DiagnosisCheckpoint(
                    'diag_subtest_pass',
                    phase_branches.DiagnosisCondition.on_all(
                        BranchDiagResult.NOT_SET),
                    action=htf.PhaseResult.FAIL_SUBTEST), phase2), phase3)

        self.assertTestPass(test_rec)
        self.assertPhasesOutcomeByName(test_record.PhaseOutcome.PASS, test_rec,
                                       'phase0', 'phase1', 'phase2', 'phase1')

        self.assertEqual([
            test_record.CheckpointRecord(
                name='diag_subtest_pass',
                action=htf.PhaseResult.FAIL_SUBTEST,
                conditional=phase_branches.DiagnosisCondition(
                    phase_branches.ConditionOn.ALL,
                    (BranchDiagResult.NOT_SET, )),
                subtest_name='subtest',
                result=phase_executor.PhaseExecutionOutcome(
                    htf.PhaseResult.CONTINUE),
                evaluated_millis=htf_test.VALID_TIMESTAMP),
        ], test_rec.checkpoints)
Exemplo n.º 2
0
    def test_subtest_fail(self):
        test_rec = yield htf.Test(
            add_set_diag,
            htf.Subtest(
                'subtest', phase0,
                phase_branches.DiagnosisCheckpoint(
                    'diag_subtest_pass',
                    phase_branches.DiagnosisCondition.on_all(
                        BranchDiagResult.SET),
                    action=htf.PhaseResult.FAIL_SUBTEST), skip0), phase1)

        self.assertTestFail(test_rec)
        self.assertPhasesOutcomeByName(test_record.PhaseOutcome.PASS, test_rec,
                                       'add_set_diag', 'phase0', 'phase1')
        self.assertPhasesOutcomeByName(test_record.PhaseOutcome.SKIP, test_rec,
                                       'skip0')

        self.assertEqual([
            test_record.CheckpointRecord(
                name='diag_subtest_pass',
                action=htf.PhaseResult.FAIL_SUBTEST,
                conditional=phase_branches.DiagnosisCondition(
                    phase_branches.ConditionOn.ALL, (BranchDiagResult.SET, )),
                subtest_name='subtest',
                result=phase_executor.PhaseExecutionOutcome(
                    htf.PhaseResult.FAIL_SUBTEST),
                evaluated_millis=htf_test.VALID_TIMESTAMP),
        ], test_rec.checkpoints)
Exemplo n.º 3
0
    def test_all_fail_subtest__fail_in_subtest(self):
        test_rec = yield htf.Test(
            phase0,
            htf.Subtest(
                'sub', phase1, fail_phase,
                phase_branches.PhaseFailureCheckpoint.all_previous(
                    'all_fail_subtest', action=htf.PhaseResult.FAIL_SUBTEST),
                skip0), phase2)

        self.assertTestFail(test_rec)
        self.assertPhasesOutcomeByName(test_record.PhaseOutcome.PASS, test_rec,
                                       'phase0', 'phase1', 'phase2')
        self.assertPhasesOutcomeByName(test_record.PhaseOutcome.SKIP, test_rec,
                                       'skip0')
        self.assertPhasesOutcomeByName(test_record.PhaseOutcome.FAIL, test_rec,
                                       'fail_phase')

        self.assertEqual([
            test_record.CheckpointRecord(
                name='all_fail_subtest',
                action=htf.PhaseResult.FAIL_SUBTEST,
                conditional=phase_branches.PreviousPhases.ALL,
                subtest_name='sub',
                result=phase_executor.PhaseExecutionOutcome(
                    htf.PhaseResult.FAIL_SUBTEST),
                evaluated_millis=htf_test.VALID_TIMESTAMP),
        ], test_rec.checkpoints)
Exemplo n.º 4
0
    def test_fail(self):
        test_rec = yield htf.Test(
            add_set_diag,
            phase_branches.DiagnosisCheckpoint(
                'diag_fail',
                phase_branches.DiagnosisCondition.on_all(
                    BranchDiagResult.SET)), error_phase)

        self.assertTestFail(test_rec)
        self.assertPhasesOutcomeByName(
            test_record.PhaseOutcome.PASS,
            test_rec,
            'add_set_diag',
        )

        self.assertEqual([
            test_record.CheckpointRecord(
                name='diag_fail',
                action=htf.PhaseResult.STOP,
                conditional=phase_branches.DiagnosisCondition(
                    phase_branches.ConditionOn.ALL, (BranchDiagResult.SET, )),
                subtest_name=None,
                result=phase_executor.PhaseExecutionOutcome(
                    htf.PhaseResult.STOP),
                evaluated_millis=htf_test.VALID_TIMESTAMP),
        ], test_rec.checkpoints)
Exemplo n.º 5
0
    def test_last_fail_subtest__early_fail_in_subtest(self):
        test_rec = yield htf.Test(
            phase0,
            htf.Subtest(
                'sub', fail_phase, phase1,
                phase_branches.PhaseFailureCheckpoint.last(
                    'last_fail_subtest', action=htf.PhaseResult.FAIL_SUBTEST),
                phase2), phase3)

        self.assertTestFail(test_rec)
        self.assertPhasesOutcomeByName(test_record.PhaseOutcome.PASS, test_rec,
                                       'phase0', 'phase1', 'phase2', 'phase3')
        self.assertPhasesOutcomeByName(test_record.PhaseOutcome.FAIL, test_rec,
                                       'fail_phase')

        self.assertEqual([
            test_record.CheckpointRecord(
                name='last_fail_subtest',
                action=htf.PhaseResult.FAIL_SUBTEST,
                conditional=phase_branches.PreviousPhases.LAST,
                subtest_name='sub',
                result=phase_executor.PhaseExecutionOutcome(
                    htf.PhaseResult.CONTINUE),
                evaluated_millis=htf_test.VALID_TIMESTAMP),
        ], test_rec.checkpoints)
Exemplo n.º 6
0
    def test_last__no_failures(self):
        test_rec = yield htf.Test(
            phase0, phase_branches.PhaseFailureCheckpoint.last('last_pass'),
            phase1)

        self.assertTestPass(test_rec)
        self.assertPhasesOutcomeByName(test_record.PhaseOutcome.PASS, test_rec,
                                       'phase0', 'phase1')

        self.assertEqual([
            test_record.CheckpointRecord(
                name='last_pass',
                action=htf.PhaseResult.STOP,
                conditional=phase_branches.PreviousPhases.LAST,
                subtest_name=None,
                result=phase_executor.PhaseExecutionOutcome(
                    htf.PhaseResult.CONTINUE),
                evaluated_millis=htf_test.VALID_TIMESTAMP),
        ], test_rec.checkpoints)
Exemplo n.º 7
0
    def test_all__fail(self):
        test_rec = yield htf.Test(
            fail_phase,
            phase_branches.PhaseFailureCheckpoint.all_previous('all_fail'),
            error_phase)

        self.assertTestFail(test_rec)
        self.assertPhasesOutcomeByName(test_record.PhaseOutcome.FAIL, test_rec,
                                       'fail_phase')

        self.assertEqual([
            test_record.CheckpointRecord(
                name='all_fail',
                action=htf.PhaseResult.STOP,
                conditional=phase_branches.PreviousPhases.ALL,
                subtest_name=None,
                result=phase_executor.PhaseExecutionOutcome(
                    htf.PhaseResult.STOP),
                evaluated_millis=htf_test.VALID_TIMESTAMP),
        ], test_rec.checkpoints)
Exemplo n.º 8
0
    def test_all__no_previous_phases(self):
        self.test_start_function = None
        test_rec = yield htf.Test(
            phase_branches.PhaseFailureCheckpoint.all_previous('all_prev'))

        self.assertTestError(test_rec)
        self.assertTestOutcomeCode(test_rec, 'NoPhasesFoundError')

        self.assertEqual([
            test_record.CheckpointRecord(
                name='all_prev',
                action=htf.PhaseResult.STOP,
                conditional=phase_branches.PreviousPhases.ALL,
                subtest_name=None,
                result=phase_executor.PhaseExecutionOutcome(
                    phase_executor.ExceptionInfo(
                        phase_branches.NoPhasesFoundError, mock.ANY,
                        mock.ANY)),
                evaluated_millis=htf_test.VALID_TIMESTAMP),
        ], test_rec.checkpoints)
Exemplo n.º 9
0
    def test_all_fail_subtest__not_in_subtest(self):
        test_rec = yield htf.Test(
            fail_phase,
            phase_branches.PhaseFailureCheckpoint.all_previous(
                'all_subtest', action=htf.PhaseResult.FAIL_SUBTEST),
            error_phase)

        self.assertTestError(test_rec)
        self.assertTestOutcomeCode(test_rec, 'InvalidPhaseResultError')
        self.assertPhasesOutcomeByName(test_record.PhaseOutcome.FAIL, test_rec,
                                       'fail_phase')

        self.assertEqual([
            test_record.CheckpointRecord(
                name='all_subtest',
                action=htf.PhaseResult.FAIL_SUBTEST,
                conditional=phase_branches.PreviousPhases.ALL,
                subtest_name=None,
                result=phase_executor.PhaseExecutionOutcome(
                    phase_executor.ExceptionInfo(
                        phase_executor.InvalidPhaseResultError, mock.ANY,
                        mock.ANY)),
                evaluated_millis=htf_test.VALID_TIMESTAMP),
        ], test_rec.checkpoints)