def test_send_batch(self, mock): self.reporter = GraphiteReporter('localhost', 3333, batch_size=2) Metrology.meter('meter').mark() Metrology.counter('counter').increment() Metrology.timer('timer').update(5) Metrology.utilization_timer('utimer').update(5) Metrology.histogram('histogram').update(5) self.reporter.write() self.assertTrue(mock.send.assert_called()) self.assertEqual(25, len(mock.sendall.call_args_list)) self.reporter.stop()
class GraphiteReporterTest(TestCase): def setUp(self): pass def tearDown(self): Metrology.stop() @patch.object(GraphiteReporter, 'socket') def test_send_nobatch(self, mock): self.reporter = GraphiteReporter('localhost', 3333, batch_size=1) Metrology.meter('meter').mark() Metrology.counter('counter').increment() Metrology.timer('timer').update(5) Metrology.utilization_timer('utimer').update(5) Metrology.histogram('histogram').update(5) self.reporter.write() self.assertTrue(mock.send.assert_called()) self.assertEqual(50, len(mock.sendall.call_args_list)) self.reporter.stop() @patch.object(GraphiteReporter, 'socket') def test_send_batch(self, mock): self.reporter = GraphiteReporter('localhost', 3333, batch_size=2) Metrology.meter('meter').mark() Metrology.counter('counter').increment() Metrology.timer('timer').update(5) Metrology.utilization_timer('utimer').update(5) Metrology.histogram('histogram').update(5) self.reporter.write() self.assertTrue(mock.send.assert_called()) self.assertEqual(25, len(mock.sendall.call_args_list)) self.reporter.stop()
class GraphiteReporterTest(TestCase): def setUp(self): pass def tearDown(self): Metrology.stop() @patch.object(GraphiteReporter, "socket") def test_send_nobatch(self, mock): self.reporter = GraphiteReporter("localhost", 3334, pickle=True, batch_size=1) Metrology.meter("meter").mark() Metrology.counter("counter").increment() Metrology.timer("timer").update(5) Metrology.utilization_timer("utimer").update(5) Metrology.histogram("histogram").update(5) self.reporter.write() self.assertTrue(mock.sendall.assert_called()) self.assertEqual(50, len(mock.sendall.call_args_list)) self.reporter.stop() @patch.object(GraphiteReporter, "socket") def test_send_batch(self, mock): self.reporter = GraphiteReporter("localhost", 3334, pickle=True, batch_size=2) Metrology.meter("meter").mark() Metrology.counter("counter").increment() Metrology.timer("timer").update(5) Metrology.utilization_timer("utimer").update(5) Metrology.histogram("histogram").update(5) self.reporter.write() self.assertTrue(mock.sendall.assert_called()) self.assertEqual(25, len(mock.sendall.call_args_list)) self.reporter.stop()
def setUp(self): self.reporter = GraphiteReporter('localhost', 3333) Metrology.meter('meter').mark() Metrology.counter('counter').increment() Metrology.timer('timer').update(1.5) Metrology.utilization_timer('utimer').update(1.5)
class GraphiteReporterTest(TestCase): def setUp(self): self.reporter = GraphiteReporter('localhost', 3333) Metrology.meter('meter').mark() Metrology.counter('counter').increment() Metrology.timer('timer').update(1.5) Metrology.utilization_timer('utimer').update(1.5) def tearDown(self): self.reporter.stop() Metrology.stop() @patch.object(GraphiteReporter, 'socket') def test_send(self, mock): self.reporter.write() self.assertTrue(mock.send.assert_called()) self.assertTrue("utimer.count 1" in mock.send.call_args_list[0][0][0])
def test_send_batch(self, mock): self.reporter = GraphiteReporter("localhost", 3334, pickle=True, batch_size=2) Metrology.meter("meter").mark() Metrology.counter("counter").increment() Metrology.timer("timer").update(5) Metrology.utilization_timer("utimer").update(5) Metrology.histogram("histogram").update(5) self.reporter.write() self.assertTrue(mock.sendall.assert_called()) self.assertEqual(25, len(mock.sendall.call_args_list)) self.reporter.stop()