@@ -244,6 +244,9 @@ def test_remove_team_member(self, m):
244
244
245
245
@requests_mock .Mocker ()
246
246
def test_get_team_preferences (self , m ):
247
+ """
248
+ Legacy method.
249
+ """
247
250
m .get (
248
251
"http://localhost/api/teams/1/preferences" ,
249
252
json = {"theme" : "" , "homeDashboardId" : 0 , "timezone" : "" },
@@ -252,7 +255,10 @@ def test_get_team_preferences(self, m):
252
255
self .assertEqual (prefs ["homeDashboardId" ], 0 )
253
256
254
257
@requests_mock .Mocker ()
255
- def test_update_team_preferences_dict (self , m ):
258
+ def test_update_team_preferences (self , m ):
259
+ """
260
+ Legacy method, using a dictionary.
261
+ """
256
262
m .put (
257
263
"http://localhost/api/teams/1/preferences" ,
258
264
json = {"message" : "Preferences updated" },
@@ -266,14 +272,29 @@ def test_update_team_preferences_dict(self, m):
266
272
self .assertEqual (updates ["message" ], "Preferences updated" )
267
273
268
274
@requests_mock .Mocker ()
269
- def test_update_team_preferences_model (self , m ):
275
+ def test_get_preferences (self , m ):
276
+ """
277
+ Modern method.
278
+ """
279
+ m .get (
280
+ "http://localhost/api/teams/1/preferences" ,
281
+ json = {"theme" : "" , "homeDashboardId" : 0 , "timezone" : "" },
282
+ )
283
+ prefs = self .grafana .teams .get_preferences ("1" )
284
+ self .assertEqual (prefs ["homeDashboardId" ], 0 )
285
+
286
+ @requests_mock .Mocker ()
287
+ def test_update_preferences (self , m ):
288
+ """
289
+ Modern method, using a `PersonalPreferences` instance.
290
+ """
270
291
m .put (
271
292
"http://localhost/api/teams/1/preferences" ,
272
293
json = {"message" : "Preferences updated" },
273
294
)
274
295
prefs = PersonalPreferences (theme = "light" , homeDashboardId = 0 , timezone = "utc" )
275
296
276
- updates = self .grafana .teams .update_team_preferences ("1" , prefs )
297
+ updates = self .grafana .teams .update_preferences ("1" , prefs )
277
298
history = m .request_history
278
299
json_payload = history [0 ].json ()
279
300
self .assertEqual (json_payload ["theme" ], "light" )
0 commit comments