Skip to content

Commit df4ee82

Browse files
committed
Add tests for grant_admin_privileges()
These tests simply check for correct query generation and exception handling if used incorrectly by passing in an empty string as username.
1 parent f723127 commit df4ee82

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

influxdb/tests/client_test.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,28 @@ def test_get_list_users_empty(self):
710710

711711
self.assertListEqual(self.cli.get_list_users(), [])
712712

713+
def test_grant_admin_privileges(self):
714+
example_response = '{"results":[{}]}'
715+
716+
with requests_mock.Mocker() as m:
717+
m.register_uri(
718+
requests_mock.GET,
719+
"http://localhost:8086/query",
720+
text=example_response
721+
)
722+
self.cli.grant_admin_privileges('test')
723+
724+
self.assertEqual(
725+
m.last_request.qs['q'][0],
726+
'grant all privileges to test'
727+
)
728+
729+
@raises(Exception)
730+
def test_grant_admin_privileges_invalid(self):
731+
cli = InfluxDBClient('host', 8086, 'username', 'password')
732+
with _mocked_session(cli, 'get', 400):
733+
self.cli.grant_admin_privileges('')
734+
713735
def test_revoke_admin_privileges(self):
714736
example_response = '{"results":[{}]}'
715737

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