Skip to content

Commit 398c94d

Browse files
committed
Add tests for get_list_users method.
1 parent 9e61b29 commit 398c94d

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

tests/influxdb/client_test.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,3 +534,34 @@ def connection_error(self, *args, **kwargs):
534534

535535
with self.assertRaises(requests.exceptions.ConnectionError):
536536
cli.write_points(self.dummy_points)
537+
538+
def test_get_list_users(self):
539+
example_response = (
540+
'{"results":[{"series":[{"columns":["user","admin"],'
541+
'"values":[["test",false]]}]}]}'
542+
)
543+
544+
with requests_mock.Mocker() as m:
545+
m.register_uri(
546+
requests_mock.GET,
547+
"http://localhost:8086/query",
548+
text=example_response
549+
)
550+
551+
self.assertListEqual(
552+
self.cli.get_list_users(),
553+
[{'user': 'test', 'admin': False}]
554+
)
555+
556+
def test_get_list_users_empty(self):
557+
example_response = (
558+
'{"results":[{"series":[{"columns":["user","admin"]}]}]}'
559+
)
560+
with requests_mock.Mocker() as m:
561+
m.register_uri(
562+
requests_mock.GET,
563+
"http://localhost:8086/query",
564+
text=example_response
565+
)
566+
567+
self.assertListEqual(self.cli.get_list_users(), [])

tests/influxdb/client_test_with_server.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,19 @@ def test_get_list_series_non_empty(self):
536536
rsp
537537
)
538538

539+
def test_get_list_users_empty(self):
540+
rsp = self.cli.get_list_users()
541+
self.assertEqual([], rsp)
542+
543+
def test_get_list_users_non_empty(self):
544+
self.cli.query("CREATE USER test WITH PASSWORD 'test'")
545+
rsp = self.cli.get_list_users()
546+
547+
self.assertEqual(
548+
[{'user': 'test', 'admin': False}],
549+
rsp
550+
)
551+
539552
def test_default_retention_policy(self):
540553
rsp = self.cli.get_list_retention_policies()
541554
self.assertEqual(

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