def test_structured_name_matcher_basic(self): metric_name = dataflow.MetricStructuredName() metric_name.name = 'metric1' metric_name.origin = 'origin2' matcher = message_matchers.MetricStructuredNameMatcher( name='metric1', origin='origin2') hc.assert_that(metric_name, hc.is_(matcher)) with self.assertRaises(AssertionError): matcher = message_matchers.MetricStructuredNameMatcher( name='metric1', origin='origin1') hc.assert_that(metric_name, hc.is_(matcher))
def test_metric_update_basic(self): metric_update = dataflow.MetricUpdate() metric_update.name = dataflow.MetricStructuredName() metric_update.name.name = 'metric1' metric_update.name.origin = 'origin1' metric_update.cumulative = False metric_update.kind = 'sum' metric_update.scalar = to_json_value(1, with_type=True) name_matcher = message_matchers.MetricStructuredNameMatcher( name='metric1', origin='origin1') matcher = message_matchers.MetricUpdateMatcher( name=name_matcher, kind='sum', scalar=1) hc.assert_that(metric_update, hc.is_(matcher)) with self.assertRaises(AssertionError): matcher.kind = 'suma' hc.assert_that(metric_update, hc.is_(matcher))