Skip to content

Commit d323bb0

Browse files
committed
chore(tests): parsing query results with bad credentials (influxdata#77)
1 parent f247f23 commit d323bb0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/test_QueryApiDataFrame.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from rx import operators as ops
88

99
from influxdb_client import InfluxDBClient, Point, WritePrecision, WriteOptions
10+
from influxdb_client.rest import ApiException
1011
from tests.base_test import BaseTest, current_milli_time
1112

1213

@@ -288,3 +289,18 @@ def _create_point(index) -> Point:
288289
result = self.client.query_api().query_data_frame(org="my-org", query=query)
289290

290291
self.assertGreater(len(result), 1)
292+
293+
def test_query_without_credentials(self):
294+
_client = InfluxDBClient(url="http://localhost:9999", token="my-token-wrong-credentials", org="my-org")
295+
296+
with self.assertRaises(ApiException) as ae:
297+
query = 'from(bucket: "my-bucket")' \
298+
'|> range(start: 2020-02-19T23:30:00Z, stop: now())' \
299+
f'|> filter(fn: (r) => r._measurement == "my-measurement")'
300+
_client.query_api().query_data_frame(query=query)
301+
302+
exception = ae.exception
303+
self.assertEqual(401, exception.status)
304+
self.assertEqual("Unauthorized", exception.reason)
305+
306+
_client.close()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy