File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,16 @@ def get_dashboard(self, dashboard_uid):
15
15
get_dashboard_path = "/dashboards/uid/%s" % dashboard_uid
16
16
r = self .client .GET (get_dashboard_path )
17
17
return r
18
+
19
+ def get_dashboard_by_name (self , dashboard_name ):
20
+ """
21
+
22
+ :param dashboard_name:
23
+ :return:
24
+ """
25
+ get_dashboard_path = "/dashboards/db/%s" % dashboard_name
26
+ r = self .client .GET (get_dashboard_path )
27
+ return r
18
28
19
29
def update_dashboard (self , dashboard ):
20
30
"""
Original file line number Diff line number Diff line change @@ -32,6 +32,30 @@ def test_get_dashboard(self, m):
32
32
)
33
33
dashboard = self .grafana .dashboard .get_dashboard ("cIBgcSjkk" )
34
34
self .assertEqual (dashboard ["dashboard" ]["uid" ], "cIBgcSjkk" )
35
+
36
+ @requests_mock .Mocker ()
37
+ def test_get_dashboard_by_name (self , m ):
38
+ m .get (
39
+ "http://localhost/api/dashboards/db/Production Overview" ,
40
+ json = {
41
+ "dashboard" : {
42
+ "id" : 1 ,
43
+ "uid" : "cIBgcSjkk" ,
44
+ "title" : "Production Overview" ,
45
+ "tags" : ["templated" ],
46
+ "timezone" : "browser" ,
47
+ "schemaVersion" : 16 ,
48
+ "version" : 0 ,
49
+ },
50
+ "meta" : {
51
+ "isStarred" : "false" ,
52
+ "url" : "/d/cIBgcSjkk/production-overview" ,
53
+ "slug" : "production-overview" ,
54
+ },
55
+ },
56
+ )
57
+ dashboard = self .grafana .dashboard .get_dashboard_by_name ("Production Overview" )
58
+ self .assertEqual (dashboard ["dashboard" ]["title" ], "Production Overview" )
35
59
36
60
@requests_mock .Mocker ()
37
61
def test_update_dashboard (self , m ):
You can’t perform that action at this time.
0 commit comments