コード例 #1
0
ファイル: core_test.py プロジェクト: beylsp/android-acts
    def test_get_binary(self):
        metric = ProtoMetric(name=self.TEST_NAME, data=self.data)
        self.data.SerializeToString = Mock()

        metric.get_binary()

        self.data.SerializeToString.assert_called_once_with()
コード例 #2
0
ファイル: core_test.py プロジェクト: beylsp/android-acts
    def test_get_descriptor_ascii(self, to_desc_proto, parse_proto):
        metric = ProtoMetric(name=self.TEST_NAME, data=self.data)
        descriptor_proto = Mock()
        to_desc_proto.return_value = descriptor_proto

        metric.get_descriptor_ascii()

        to_desc_proto.assert_called_once_with(self.data)
        parse_proto.assert_called_once_with(descriptor_proto)
コード例 #3
0
ファイル: core_test.py プロジェクト: beylsp/android-acts
    def test_get_descriptor_binary(self, to_descriptor_proto):
        metric = ProtoMetric(name=self.TEST_NAME, data=self.data)
        descriptor_proto = Mock()
        descriptor_proto.SerializeToString = Mock()
        to_descriptor_proto.return_value = descriptor_proto

        metric.get_descriptor_binary()

        to_descriptor_proto.assert_called_once_with(self.data)
        descriptor_proto.SerializeToString.assert_called_once_with()
コード例 #4
0
 def get_proto_dict(self, test, proto):
     """Return dict with proto, readable ascii proto, and test name."""
     return {
         'proto':
         base64.b64encode(ProtoMetric(test,
                                      proto).get_binary()).decode('utf-8'),
         'proto_ascii':
         ProtoMetric(test, proto).get_ascii(),
         'test_name':
         test
     }
コード例 #5
0
    def test_usage_map_to_proto_metric(self, current_context):
        context = TestCaseContext('a', 'b')
        current_context.return_value = context
        publisher = UsageMetadataPublisher()

        umk1 = UsageMetadataKey('a.b', 'c.d')
        umk2 = UsageMetadataKey('e.f', 'h.i')
        _usage_map[umk1] = 51
        _usage_map[umk2] = 5

        usage_metadata_proto = acts_usage_metadata_pb2.ActsTestRunMetadata()
        method_invocation = usage_metadata_proto.usage.add()
        method_invocation.method_identifier = 'a.b'
        method_invocation.test_context = 'c.d'
        method_invocation.count = 51
        method_invocation = usage_metadata_proto.usage.add()
        method_invocation.method_identifier = 'e.f'
        method_invocation.test_context = 'h.i'
        method_invocation.count = 5

        expected = ProtoMetric(name='acts_usage_metadata',
                               data=usage_metadata_proto)

        actual = publisher._usage_map_to_proto_metric()
        self.assertEqual(expected.name, actual.name)
        self.assertEqual(parse_proto_to_ascii(expected.data),
                         parse_proto_to_ascii(actual.data))
コード例 #6
0
    def end(self, _):
        """Creates and publishes a ProtoMetric with bounded_pb2.Metric data.

        Builds a list of bounded_pb2.Metric messages from the set
        metric data, and sends them to the publisher.
        """
        metrics = []
        for metric_name, bounded_metric in self._metric_map.items():
            if bounded_metric is None:
                continue
            metrics.append(
                ProtoMetric(name='bounded_metric_%s' % metric_name,
                            data=bounded_metric))
        return self.publisher.publish(metrics)
コード例 #7
0
    def _usage_map_to_proto_metric(self):
        """Iterate over _usage_map, creating an ActsMethodUsageMetadata for
        each entry.

        Returns:
            ProtoMetric wrapper object with name='acts_usage_metadata' and
            data=ActsTestRunMetadata()
        """
        data = acts_usage_metadata_pb2.ActsTestRunMetadata()

        for usage in _usage_map:
            method_count = data.usage.add()
            method_count.test_context = usage.test_context
            method_count.method_identifier = usage.method_name
            method_count.count = _usage_map[usage]

        return ProtoMetric(name='acts_usage_metadata', data=data)
コード例 #8
0
    def end(self, _):
        """Creates and publishes a ProtoMetric with blackbox data.

        Builds a list of ActsBlackboxMetricResult messages from the set
        metric data, and sends them to the publisher.
        """
        metrics = []
        for metric_name, metric_value in self._metric_map.items():
            if metric_value is None:
                continue
            result = acts_blackbox_pb2.ActsBlackboxMetricResult()
            result.test_identifier = self._get_blackbox_identifier()
            result.metric_key = self._get_metric_key(metric_name)
            result.metric_value = metric_value

            metrics.append(
                ProtoMetric(name='blackbox_%s' % metric_name, data=result))

        return self.publisher.publish(metrics)
コード例 #9
0
 def end(self, event):
     metric = ProtoMetric(name='telephony_voice_test_result',
                          data=self.proto)
     return self.publisher.publish(metric)
コード例 #10
0
ファイル: core_test.py プロジェクト: beylsp/android-acts
    def test_get_ascii(self, parse_proto_to_ascii):
        metric = ProtoMetric(name=self.TEST_NAME, data=self.data)

        metric.get_ascii()

        parse_proto_to_ascii.assert_called_once_with(self.data)
コード例 #11
0
ファイル: core_test.py プロジェクト: beylsp/android-acts
 def test_no_data_init_raises_error(self):
     self.assertRaises(ValueError, lambda: ProtoMetric(name=self.TEST_NAME))
コード例 #12
0
ファイル: core_test.py プロジェクト: beylsp/android-acts
 def test_default_init_attributes(self):
     metric = ProtoMetric(name = self.TEST_NAME, data=self.data)
     self.assertEqual(metric.name, self.TEST_NAME)
     self.assertEqual(metric.data, self.data)
コード例 #13
0
 def add_proto_to_results(self, proto, test):
     """Adds proto as ProtoMetric object to self.results."""
     self.results.append(ProtoMetric(test, proto))
コード例 #14
0
 def end(self, event):
     metric = ProtoMetric(name='spanner_power_metric', data=self.proto)
     return self.publisher.publish(metric)