Exemplo n.º 1
0
    def test_phase_diagnoser_exception__later_phases_not_run(self):
        fail_phase = htf.PhaseOptions(name='fail')(
            htf.diagnose(exception_phase_diag)(basic_phase))
        not_run_phase = htf.PhaseOptions(name='not_run')(basic_phase)

        test_rec = yield htf.Test(fail_phase, not_run_phase)

        self.assertTestError(test_rec)
        self.assertPhaseError(test_rec.phases[1], exc_type=DiagPhaseError)
        self.assertEqual(2, len(test_rec.phases))
Exemplo n.º 2
0
    def test_test_record_diagnosis_serialization(self):
        phase1 = htf.PhaseOptions(name='pass_diag_phase')(
            htf.diagnose(basic_wrapper_phase_diagnoser)(basic_phase))
        phase2 = htf.PhaseOptions(name='fail_diag_phase')(
            htf.diagnose(fail_phase_diagnoser)(basic_phase))

        test = htf.Test(phase1, phase2)
        test.add_test_diagnosers(basic_wrapper_test_diagnoser)

        test_rec = yield test

        self.assertTestFail(test_rec)
        self.assertPhaseOutcomePass(test_rec.phases[1])
        self.assertPhaseOutcomeFail(test_rec.phases[2])

        converted = data.convert_to_base_types(test_rec)
        self.assertEqual([
            {
                'result': 'okay',
                'description': 'Everything is okay.',
                'component': None,
                'priority': 'NORMAL',
            },
            {
                'result': 'bad_one',
                'description': 'Oh no!',
                'component': None,
                'priority': 'NORMAL',
                'is_failure': True,
            },
            {
                'result': 'test_ok',
                'description': 'Okay',
                'component': None,
                'priority': 'NORMAL',
            },
        ], converted['diagnoses'])

        self.assertEqual(['okay'], converted['phases'][1]['diagnosis_results'])
        self.assertEqual([],
                         converted['phases'][1]['failure_diagnosis_results'])

        self.assertEqual([], converted['phases'][2]['diagnosis_results'])
        self.assertEqual(['bad_one'],
                         converted['phases'][2]['failure_diagnosis_results'])
Exemplo n.º 3
0
 def test_call_overrides_phase_result(self):
     phase = openhtf.PhaseOptions(
         stop_on_measurement_fail=True)(partially_passing_phase)
     record = self.execute_phase_or_test(
         openhtf.Test(passing_phase, phase, passing_phase))
     self.assertEqual(record.outcome, test_record.Outcome.FAIL)
     self.assertEqual(record.phases[-1].name, phase.name)
     self.assertEqual(record.phases[-1].result.phase_result,
                      openhtf.PhaseResult.STOP)
Exemplo n.º 4
0
def _prefix_name(phase):
    return htf.PhaseOptions(name='prefix:' + phase.name)(phase)
Exemplo n.º 5
0
def _rename(phase, new_name):
    assert isinstance(new_name, str)
    return htf.PhaseOptions(name=new_name)(phase)