def test_replace_tagged(self): tags = {"test": "true"} gauge = metrics.Gauge(self.transport, b"example", tags) gauge.replace(33) self.assertEqual(self.transport.send.call_count, 1) self.assertEqual(self.transport.send.call_args, mock.call(b"example,test=true:33|g"))
def test_replace(self): gauge = metrics.Gauge(self.transport, b"example") gauge.replace(33) self.assertIsNone(gauge.tags) self.assertEqual(self.transport.send.call_count, 1) self.assertEqual(self.transport.send.call_args, mock.call(b"example:33|g"))
def test_replace_disallow_negative(self): gauge = metrics.Gauge(self.transport, b"example") with self.assertRaises(Exception): gauge.replace(-2)