@@ -776,6 +776,31 @@ def test_revoke_privilege_invalid(self):
776
776
with _mocked_session (cli , 'get' , 400 ):
777
777
self .cli .revoke_privilege ('' , 'testdb' , 'test' )
778
778
779
+ def test_get_list_privileges (self ):
780
+ data = {'results' : [
781
+ {'series' : [
782
+ {'columns' : ['database' , 'privilege' ],
783
+ 'values' : [
784
+ ['db1' , 'READ' ],
785
+ ['db2' , 'ALL PRIVILEGES' ],
786
+ ['db3' , 'NO PRIVILEGES' ]]}
787
+ ]}
788
+ ]}
789
+
790
+ with _mocked_session (self .cli , 'get' , 200 , json .dumps (data )):
791
+ self .assertListEqual (
792
+ self .cli .get_list_privileges ('test' ),
793
+ [{'database' : 'db1' , 'privilege' : 'READ' },
794
+ {'database' : 'db2' , 'privilege' : 'ALL PRIVILEGES' },
795
+ {'database' : 'db3' , 'privilege' : 'NO PRIVILEGES' }]
796
+ )
797
+
798
+ @raises (Exception )
799
+ def test_get_list_privileges_fails (self ):
800
+ cli = InfluxDBClient ('host' , 8086 , 'username' , 'password' )
801
+ with _mocked_session (cli , 'get' , 401 ):
802
+ cli .get_list_privileges ('test' )
803
+
779
804
def test_invalid_port_fails (self ):
780
805
with self .assertRaises (ValueError ):
781
806
InfluxDBClient ('host' , '80/redir' , 'username' , 'password' )
0 commit comments