def setUp(self): super(TestClient, self).setUp() self.mock_queue = [] with patch.object(librato, 'connect') as mock_connect: mock_connect.return_value = MockConnection(self.mock_queue) self.client = Client('test-user', '1234567890', debug=True)
class TestClient(unittest.TestCase): def setUp(self): super(TestClient, self).setUp() self.mock_queue = [] with patch.object(librato, 'connect') as mock_connect: mock_connect.return_value = MockConnection(self.mock_queue) self.client = Client('test-user', '1234567890', debug=True) def test_gauge(self): self.client.gauge('librato_bg.test', 105, 'lagom') self.client.flush() self.assertEqual(self.mock_queue, [{'name': 'librato_bg.test', 'source': 'lagom', 'value': 105}])
class TestClient(unittest.TestCase): def setUp(self): super(TestClient, self).setUp() self.mock_queue = [] with patch.object(librato, 'connect') as mock_connect: mock_connect.return_value = MockConnection(self.mock_queue) self.client = Client('test-user', '1234567890', debug=True) def test_gauge(self): self.client.gauge('librato_bg.test', 105, 'lagom') self.client.flush() self.assertEqual(self.mock_queue, [{ 'name': 'librato_bg.test', 'source': 'lagom', 'value': 105 }])
def init_librato(user, token): global _librato _librato = Client(user, token) # pragma: needs cover
class TestClient(unittest.TestCase): def setUp(self): super(TestClient, self).setUp() self.mock_queue = [] with patch.object(librato, 'connect') as mock_connect: mock_connect.return_value = MockConnection(self.mock_queue) self.client = Client('test-user', '1234567890', debug=True) def test_gauge(self): self.client.gauge('librato_bg.test', 105, 'lagom') self.client.flush() self.assertEqual(self.mock_queue, [{'name': 'librato_bg.test', 'source': 'lagom', 'value': 105}]) if __name__ == '__main__': """ We can also test against a real Librato account """ user = os.environ.get('LIBRATO_USER') token = os.environ.get('LIBRATO_TOKEN') assert user and token, "Must set LIBRATO_USER and LIBRATO_TOKEN to run tests" client = Client(user, token, debug=True) for i in range(1000): client.gauge('librato_bg.test', i, 'lagom') client.flush()
def init_librato(user, token): global _librato _librato = Client(user, token)
self.mock_queue = [] with patch.object(librato, 'connect') as mock_connect: mock_connect.return_value = MockConnection(self.mock_queue) self.client = Client('test-user', '1234567890', debug=True) def test_gauge(self): self.client.gauge('librato_bg.test', 105, 'lagom') self.client.flush() self.assertEqual(self.mock_queue, [{ 'name': 'librato_bg.test', 'source': 'lagom', 'value': 105 }]) if __name__ == '__main__': """ We can also test against a real Librato account """ user = os.environ.get('LIBRATO_USER') token = os.environ.get('LIBRATO_TOKEN') assert user and token, "Must set LIBRATO_USER and LIBRATO_TOKEN to run tests" client = Client(user, token, debug=True) for i in range(1000): client.gauge('librato_bg.test', i, 'lagom') client.flush()