def test_mfg_event_from_test_record(self): """Test for the full conversion flow.""" record = test_record.TestRecord( dut_id='dut_serial', start_time_millis=1, end_time_millis=1, station_id='localhost', outcome=test_record.Outcome.PASS, ) record.outcome = test_record.Outcome.PASS record.metadata = { 'assembly_events': [assembly_event_pb2.AssemblyEvent()] * 2, 'config': {'mock-config-key': 'mock-config-value'}, 'operator_name': 'mock-operator-name', } record.phases = [ test_record.PhaseRecord( name='phase-%d' % idx, descriptor_id=idx, codeinfo=test_record.CodeInfo.uncaptured(), result=None, attachments={}, start_time_millis=1, end_time_millis=1 ) for idx in range(1, 5) ] for phase in record.phases: phase.measurements = { 'meas-1': measurements.Measurement('meas-1'), 'meas-2': measurements.Measurement('meas-2'), 'meas-3': measurements.Measurement('meas-3').with_dimensions('V'), } phase.attachments = { 'attach-1': test_record.Attachment(data='data-1', mimetype=''), 'attach-2': test_record.Attachment(data='data-2', mimetype=''), } mfg_event = mfg_event_converter.mfg_event_from_test_record(record) self.assertEqual(mfg_event.dut_serial, record.dut_id) self.assertEqual(len(mfg_event.assembly_events), 2) self.assertEqual(len(mfg_event.measurement), 8) self.assertEqual(sorted(m.name for m in mfg_event.measurement), ['meas-1_0', 'meas-1_1', 'meas-1_2', 'meas-1_3', 'meas-2_0', 'meas-2_1', 'meas-2_2', 'meas-2_3']) self.assertEqual(len(mfg_event.attachment), 15) self.assertEqual(sorted(str(m.name) for m in mfg_event.attachment), ['OpenHTF_record.json', 'argv', 'attach-1_0', 'attach-1_1', 'attach-1_2', 'attach-1_3', 'attach-2_0', 'attach-2_1', 'attach-2_2', 'attach-2_3', 'config', 'multidim_meas-3_0', 'multidim_meas-3_1', 'multidim_meas-3_2', 'multidim_meas-3_3'])
def test_mfg_event_from_test_record(self): """Test for the full conversion flow.""" record = test_record.TestRecord( dut_id='dut_serial', start_time_millis=1, end_time_millis=1, station_id='localhost', outcome=test_record.Outcome.PASS, ) record.outcome = test_record.Outcome.PASS record.metadata = { 'assembly_events': [assembly_event_pb2.AssemblyEvent()] * 2, 'config': {'mock-config-key': 'mock-config-value'}, 'operator_name': 'mock-operator-name', } record.phases = [ test_record.PhaseRecord( name='phase-%d' % idx, descriptor_id=idx, codeinfo=test_record.CodeInfo.uncaptured(), result=None, attachments={}, start_time_millis=1, end_time_millis=1) for idx in range(1, 5) ] for phase in record.phases: phase.measurements = { 'meas-1': measurements.Measurement('meas-1'), 'meas-2': measurements.Measurement('meas-2'), 'meas-3': measurements.Measurement('meas-3').with_dimensions('V'), } phase.attachments = { 'attach-1': test_record.Attachment(data='data-1', mimetype=''), 'attach-2': test_record.Attachment(data='data-2', mimetype=''), } mfg_event = mfg_event_converter.mfg_event_from_test_record(record) self.assertEqual(mfg_event.dut_serial, record.dut_id) self.assertEqual(len(mfg_event.assembly_events), 2) self.assertEqual(len(mfg_event.measurement), 8) self.assertEqual(sorted(m.name for m in mfg_event.measurement), ['meas-1_0', 'meas-1_1', 'meas-1_2', 'meas-1_3', 'meas-2_0', 'meas-2_1', 'meas-2_2', 'meas-2_3']) self.assertEqual(len(mfg_event.attachment), 15) self.assertEqual(sorted(str(m.name) for m in mfg_event.attachment), ['OpenHTF_record.json', 'argv', 'attach-1_0', 'attach-1_1', 'attach-1_2', 'attach-1_3', 'attach-2_0', 'attach-2_1', 'attach-2_2', 'attach-2_3', 'config', 'multidim_meas-3_0', 'multidim_meas-3_1', 'multidim_meas-3_2', 'multidim_meas-3_3'])
def test_mfg_event_from_test_record(self, user_mock): user_mock.prompt.return_value = 'SomeWidget' record = yield self._test mfg_event = mfg_event_converter.mfg_event_from_test_record(record) callback = console_summary.ConsoleSummary() callback(record) # Assert test status self.assertEqual(test_runs_pb2.PASS, mfg_event.test_status) # Verify all expected phases included. expected_phase_names = [ 'trigger_phase', 'hello_world', 'dimensions', 'attachments', 'hello_world', 'attachments' ] actual_phase_names = [phase.name for phase in mfg_event.phases] self.assertEqual(expected_phase_names, actual_phase_names) # Spot check duplicate measurements (widget_size) for measurement_name in ['widget_size_0', 'widget_size_1']: for measurement in mfg_event.measurement: if measurement.name == measurement_name: self.assertEqual(3.0, measurement.numeric_value) break else: raise AssertionError('No measurement named %s' % measurement_name) # Spot check an attachment (example_attachment.txt) for attachment_name in [ 'example_attachment_0.txt', 'example_attachment_1.txt' ]: for attachment in mfg_event.attachment: if attachment.name == attachment_name: self.assertEqual( b'This is a text file attachment.\n', attachment.value_binary, ) break else: raise AssertionError('No attachment named %s' % attachment_name)
def test_mfg_event_from_test_record(self, user_mock): user_mock.prompt.return_value = 'SomeWidget' record = yield self._test mfg_event = mfg_event_converter.mfg_event_from_test_record(record) callback = console_summary.ConsoleSummary() callback(record) # Assert test status self.assertEqual(test_runs_pb2.PASS, mfg_event.test_status) # Verify all expected phases included. expected_phase_names = [ 'trigger_phase', 'hello_world', 'dimensions', 'attachments', 'hello_world', 'attachments' ] actual_phase_names = [phase.name for phase in mfg_event.phases] self.assertEqual(expected_phase_names, actual_phase_names) # Spot check duplicate measurements (widget_size) for measurement_name in ['widget_size_0', 'widget_size_1']: for measurement in mfg_event.measurement: if measurement.name == measurement_name: self.assertEqual(3.0, measurement.numeric_value) break else: raise AssertionError('No measurement named %s' % measurement_name) # Spot check an attachment (example_attachment.txt) for attachment_name in ['example_attachment_0.txt', 'example_attachment_1.txt']: for attachment in mfg_event.attachment: if attachment.name == attachment_name: self.assertEqual( b'This is a text file attachment.\n', attachment.value_binary, ) break else: raise AssertionError('No attachment named %s' % attachment_name)