Пример #1
0
    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)
Пример #2
0
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}])
Пример #3
0
    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)
Пример #4
0
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
        }])
Пример #5
0
def init_librato(user, token):
    global _librato
    _librato = Client(user, token)  # pragma: needs cover
Пример #6
0
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()
Пример #7
0
def init_librato(user, token):
    global _librato
    _librato = Client(user, token)
Пример #8
0
        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()