Exemple #1
0
    def test_end_uses_custom_metric_key(self, mock_acts_blackbox):
        result = Mock()
        mock_acts_blackbox.return_value = result
        metric_key = 'metric_key'

        logger = BlackboxMetricLogger(self.TEST_METRIC_NAME,
                                      metric_key=metric_key)
        logger.context = self.context
        logger.publisher = self.publisher
        logger._get_blackbox_identifier = self._get_blackbox_identifier
        logger.metric_value = 'foo'

        logger.end(self.event)

        expected_metric_key = '%s.%s' % (metric_key, self.TEST_METRIC_NAME)
        self.assertEqual(result.metric_key, expected_metric_key)
Exemple #2
0
    def test_end_does_publish(self, mock_acts_blackbox, proto_metric_cls):
        result = Mock()
        mock_acts_blackbox.return_value = result
        metric_key = 'metric_key'

        logger = BlackboxMetricLogger(self.TEST_METRIC_NAME,
                                      metric_key=metric_key)
        logger.context = self.context
        logger.publisher = self.publisher
        logger._get_blackbox_identifier = self._get_blackbox_identifier
        logger.metric_value = 'foo'

        logger.end(self.event)

        proto_metric_cls.assert_called_once_with(name=self.TEST_FILE_NAME,
                                                 data=result)
        self.publisher.publish.assert_called_once_with(
            [proto_metric_cls.return_value])