def test_influx_service_not_inited(self): self.setUpLogging() self.patch(storage_backends.influxdb_client, 'InfluxDBClient', fakestats.FakeInfluxDBClient) svc = InfluxStorageService( "fake_url", "fake_port", "fake_user", "fake_password", "fake_db", "fake_stats") svc._inited = False svc.thd_postStatsValue("test", "test", "test") self.assertLogged("Service.*not initialized")
def test_influx_storage_service_post_value(self): # test the thd_postStatsValue method of InfluxStorageService self.patch(storage_backends.influxdb_client, 'InfluxDBClient', fakestats.FakeInfluxDBClient) svc = InfluxStorageService("fake_url", "fake_port", "fake_user", "fake_password", "fake_db", "fake_stats") post_data = {'name': 'test', 'value': 'test'} context = {'x': 'y'} svc.thd_postStatsValue(post_data, "test_series_name", context) data = { 'measurement': "test_series_name", 'fields': { "name": "test", "value": "test" }, 'tags': { 'x': 'y' } } points = [data] self.assertEqual(svc.client.points, points)
def test_influx_storage_service_post_value(self): # test the thd_postStatsValue method of InfluxStorageService self.patch(storage_backends.influxdb_client, 'InfluxDBClient', fakestats.FakeInfluxDBClient) svc = InfluxStorageService( "fake_url", "fake_port", "fake_user", "fake_password", "fake_db", "fake_stats") post_data = { 'name': 'test', 'value': 'test' } context = {'x': 'y'} svc.thd_postStatsValue(post_data, "test_series_name", context) data = { 'measurement': "test_series_name", 'fields': { "name": "test", "value": "test" }, 'tags': {'x': 'y'} } points = [data] self.assertEquals(svc.client.points, points)