def test_reversibleish(self): """Verify that in happy case multidim -> attachment is reversible.""" mdim = self.create_multi_dim_measurement() attachment = mfg_event_converter.multidim_measurement_to_attachment( name='test_measurement_multidim', measurement=mdim) reversed_mdim = mfg_event_converter.attachment_to_multidim_measurement( attachment) self.assert_same_mdim(mdim, reversed_mdim)
def test_reversibleish(self): """Verify that in happy case multidim -> attachment is reversible.""" mdim = self.create_multi_dim_measurement() attachment = mfg_event_converter.multidim_measurement_to_attachment( name='test_measurement_multidim', measurement=mdim) reversed_mdim = mfg_event_converter.attachment_to_multidim_measurement( attachment) self.assert_same_mdim(mdim, reversed_mdim)
def test_attachment_to_multidim_measurement(self): expected = self.create_multi_dim_measurement() attachment = test_record.Attachment(TEST_MULTIDIM_JSON, test_runs_pb2.MULTIDIM_JSON) measurement = mfg_event_converter.attachment_to_multidim_measurement( attachment) self.assertEqual(expected.measured_value.value, measurement.measured_value.value) for exp, act in zip(expected.dimensions, measurement.dimensions): self.assertEqual(exp, act)
def test_attachment_to_multidim_measurement(self): expected = self.create_multi_dim_measurement() attachment = test_record.Attachment(TEST_MULTIDIM_JSON, test_runs_pb2.MULTIDIM_JSON) measurement = mfg_event_converter.attachment_to_multidim_measurement( attachment) self.assertEqual(expected.measured_value.value, measurement.measured_value.value) for exp, act in zip(expected.dimensions, measurement.dimensions): self.assertEqual(exp, act)
def test_reversibleish_leagcy_status_int(self): """Verfiy multidim -> attachment is reversible even on leagacy data. Older implementations would cast the outcome to an int instead of a string. We verify we can cast the saved int into correct outcome. """ mdim = self.create_multi_dim_measurement() attachment = mfg_event_converter.multidim_measurement_to_attachment( name='test_measurement_multidim', measurement=mdim) # Re-parse the data, edit the outcome field to a int, then reserialize. data_dict = json.loads(attachment.data) data_dict['outcome'] = test_runs_pb2.Status.Value(data_dict['outcome']) attachment = test_record.Attachment(json.dumps(data_dict), test_runs_pb2.MULTIDIM_JSON) reversed_mdim = mfg_event_converter.attachment_to_multidim_measurement( attachment) self.assert_same_mdim(mdim, reversed_mdim)
def test_reversibleish_leagcy_status_int(self): """Verfiy multidim -> attachment is reversible even on leagacy data. Older implementations would cast the outcome to an int instead of a string. We verify we can cast the saved int into correct outcome. """ mdim = self.create_multi_dim_measurement() attachment = mfg_event_converter.multidim_measurement_to_attachment( name='test_measurement_multidim', measurement=mdim) # Re-parse the data, edit the outcome field to a int, then reserialize. data_dict = json.loads(attachment.data) data_dict['outcome'] = test_runs_pb2.Status.Value(data_dict['outcome']) attachment = test_record.Attachment(json.dumps(data_dict), test_runs_pb2.MULTIDIM_JSON) reversed_mdim = mfg_event_converter.attachment_to_multidim_measurement( attachment) self.assert_same_mdim(mdim, reversed_mdim)