Skip to content

Commit b3c04e1

Browse files
committed
Add tests for drop_user method.
1 parent 72f66d4 commit b3c04e1

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/influxdb/client_test_with_server.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,27 @@ def test_create_user_invalid_username(self):
355355
rsp = list(self.cli.query("SHOW USERS")['results'])
356356
self.assertEqual(rsp, [])
357357

358+
def test_drop_user(self):
359+
self.cli.query("CREATE USER test WITH PASSWORD 'test'")
360+
self.cli.drop_user('test')
361+
users = list(self.cli.query("SHOW USERS")['results'])
362+
self.assertEqual(users, [])
363+
364+
def test_drop_user_nonexisting(self):
365+
with self.assertRaises(InfluxDBClientError) as ctx:
366+
self.cli.drop_user('test')
367+
self.assertEqual(500, ctx.exception.code)
368+
self.assertIn('{"results":[{"error":"user not found"}]}',
369+
ctx.exception.content)
370+
371+
def test_drop_user_invalid(self):
372+
with self.assertRaises(InfluxDBClientError) as ctx:
373+
self.cli.drop_user('very invalid')
374+
self.assertEqual(400, ctx.exception.code)
375+
self.assertIn('{"error":"error parsing query: '
376+
'found invalid, expected',
377+
ctx.exception.content)
378+
358379

359380
############################################################################
360381

0 commit comments

Comments
 (0)