예제 #1
0
  def test_populate_basic_data(self):
    outcome_details = test_record.OutcomeDetails(
        code='mock-code',
        description='mock-description',
    )
    phase = test_record.PhaseRecord(
        name='mock-phase-name',
        descriptor_id=1,
        codeinfo=self.create_codeinfo(),
        start_time_millis=200,
        end_time_millis=400,
    )
    log_record = test_logs.LogRecord(
        level=logging.INFO,
        logger_name='mock-logger-name',
        source='mock-source',
        lineno=123,
        timestamp_millis=300,
        message='mock-message',
    )
    record = test_record.TestRecord(
        dut_id='mock-dut-id',
        station_id='mock-station-id',
        start_time_millis=100,
        end_time_millis=500,
        outcome=test_record.Outcome.PASS,
        outcome_details=[outcome_details],
        metadata={
            'test_name': 'mock-test-name',
            'operator_name': 'mock-operator-name',
            'test_version': 1.0,
            'test_description': 'mock-test-description',
        },
        phases=[phase],
        log_records=[log_record],
    )

    mfg_event = mfg_event_pb2.MfgEvent()
    mfg_event_converter._populate_basic_data(mfg_event, record)

    self.assertEqual(mfg_event.dut_serial, 'mock-dut-id')
    self.assertEqual(mfg_event.start_time_ms, 100)
    self.assertEqual(mfg_event.end_time_ms, 500)
    self.assertEqual(mfg_event.tester_name, 'mock-station-id')
    self.assertEqual(mfg_event.test_name, 'mock-test-name')
    self.assertEqual(mfg_event.test_version, '1.0')
    self.assertEqual(mfg_event.test_description, 'mock-test-description')
    self.assertEqual(mfg_event.test_status, test_runs_pb2.PASS)

    # Phases.
    self.assertEqual(mfg_event.phases[0].name, 'mock-phase-name')
    self.assertEqual(mfg_event.phases[0].description, 'mock-sourcecode')
    self.assertEqual(mfg_event.phases[0].timing.start_time_millis, 200)
    self.assertEqual(mfg_event.phases[0].timing.end_time_millis, 400)

    # Failure codes.
    self.assertEqual(mfg_event.failure_codes[0].code, 'mock-code')
    self.assertEqual(mfg_event.failure_codes[0].details, 'mock-description')

    # Test logs.
    self.assertEqual(mfg_event.test_logs[0].timestamp_millis, 300)
    self.assertEqual(mfg_event.test_logs[0].log_message, 'mock-message')
    self.assertEqual(mfg_event.test_logs[0].logger_name, 'mock-logger-name')
    self.assertEqual(mfg_event.test_logs[0].levelno, logging.INFO)
    self.assertEqual(mfg_event.test_logs[0].level,
                     test_runs_pb2.TestRunLogMessage.INFO)
    self.assertEqual(mfg_event.test_logs[0].log_source, 'mock-source')
    self.assertEqual(mfg_event.test_logs[0].lineno, 123)
예제 #2
0
  def test_populate_basic_data(self):
    outcome_details = test_record.OutcomeDetails(
        code='mock-code',
        description='mock-description',
    )
    phase = test_record.PhaseRecord(
        name='mock-phase-name',
        descriptor_id=1,
        codeinfo=self.create_codeinfo(),
        start_time_millis=200,
        end_time_millis=400,
    )
    log_record = test_logs.LogRecord(
        level=logging.INFO,
        logger_name='mock-logger-name',
        source='mock-source',
        lineno=123,
        timestamp_millis=300,
        message='mock-message',
    )
    record = test_record.TestRecord(
        dut_id='mock-dut-id',
        station_id='mock-station-id',
        start_time_millis=100,
        end_time_millis=500,
        outcome=test_record.Outcome.PASS,
        outcome_details=[outcome_details],
        metadata={
            'test_name': 'mock-test-name',
            'operator_name': 'mock-operator-name',
            'test_version': 1.0,
            'test_description': 'mock-test-description',
        },
        phases=[phase],
        log_records=[log_record],
    )

    mfg_event = mfg_event_pb2.MfgEvent()
    mfg_event_converter._populate_basic_data(mfg_event, record)

    self.assertEqual(mfg_event.dut_serial, 'mock-dut-id')
    self.assertEqual(mfg_event.start_time_ms, 100)
    self.assertEqual(mfg_event.end_time_ms, 500)
    self.assertEqual(mfg_event.tester_name, 'mock-station-id')
    self.assertEqual(mfg_event.test_name, 'mock-test-name')
    self.assertEqual(mfg_event.test_version, '1.0')
    self.assertEqual(mfg_event.test_description, 'mock-test-description')
    self.assertEqual(mfg_event.test_status, test_runs_pb2.PASS)

    # Phases.
    self.assertEqual(mfg_event.phases[0].name, 'mock-phase-name')
    self.assertEqual(mfg_event.phases[0].description, 'mock-sourcecode')
    self.assertEqual(mfg_event.phases[0].timing.start_time_millis, 200)
    self.assertEqual(mfg_event.phases[0].timing.end_time_millis, 400)

    # Failure codes.
    self.assertEqual(mfg_event.failure_codes[0].code, 'mock-code')
    self.assertEqual(mfg_event.failure_codes[0].details, 'mock-description')

    # Test logs.
    self.assertEqual(mfg_event.test_logs[0].timestamp_millis, 300)
    self.assertEqual(mfg_event.test_logs[0].log_message, 'mock-message')
    self.assertEqual(mfg_event.test_logs[0].logger_name, 'mock-logger-name')
    self.assertEqual(mfg_event.test_logs[0].levelno, logging.INFO)
    self.assertEqual(mfg_event.test_logs[0].level,
                     test_runs_pb2.TestRunLogMessage.INFO)
    self.assertEqual(mfg_event.test_logs[0].log_source, 'mock-source')
    self.assertEqual(mfg_event.test_logs[0].lineno, 123)