Exemplo n.º 1
0
  def test_multidim_measurement_to_attachment(self):
    """Test for the full conversion flow."""
    meas = self.create_multi_dim_measurement()

    attachment = mfg_event_converter.multidim_measurement_to_attachment(
        name='test_measurement_multidim', measurement=meas)

    self.assertEqual(
        json.loads(TEST_MULTIDIM_JSON), json.loads(attachment.data))
Exemplo n.º 2
0
  def test_multidim_measurement_to_attachment(self):
    """Test for the full conversion flow."""
    meas = self.create_multi_dim_measurement()

    attachment = mfg_event_converter.multidim_measurement_to_attachment(
        name='test_measurement_multidim', measurement=meas)

    self.assertEqual(
        json.loads(TEST_MULTIDIM_JSON), json.loads(attachment.data))
Exemplo n.º 3
0
  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)
Exemplo n.º 4
0
  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)
Exemplo n.º 5
0
  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)
Exemplo n.º 6
0
  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)