Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
szuro authored and amotl committed Nov 7, 2023
1 parent f6583e2 commit 14f0e4c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
4 changes: 2 additions & 2 deletions grafana_client/elements/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def set_user_enabled(self, user_id, enabled: bool):
:param enabled:
:return:
"""
action = 'enable' if enabled else 'disable'
set_user_enabled = '/admin/users/%s/%s' % (user_id, action)
action = "enable" if enabled else "disable"
set_user_enabled = "/admin/users/%s/%s" % (user_id, action)
r = self.client.POST(set_user_enabled)
return r
10 changes: 2 additions & 8 deletions test/elements/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,18 +184,12 @@ def test_pause_all_alerts(self, m):

@requests_mock.Mocker()
def test_enable_user(self, m):
m.post(
"http://localhost/api/admin/users/2/enable",
json={"message": "User enabled"}
)
m.post("http://localhost/api/admin/users/2/enable", json={"message": "User enabled"})
user = self.grafana.admin.set_user_enabled(user_id=2, enabled=True)
self.assertEqual(user["message"], "User enabled")

@requests_mock.Mocker()
def test_disable_user(self, m):
m.post(
"http://localhost/api/admin/users/2/disable",
json={"message": "User disabled"}
)
m.post("http://localhost/api/admin/users/2/disable", json={"message": "User disabled"})
user = self.grafana.admin.set_user_enabled(user_id=2, enabled=False)
self.assertEqual(user["message"], "User disabled")

0 comments on commit 14f0e4c

Please sign in to comment.