summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--grafana_dashboards/schema/dashboard.py1
-rw-r--r--tests/schema/fixtures/dashboard-0001.json1
-rw-r--r--tests/schema/fixtures/dashboard-0002.json1
-rw-r--r--tests/schema/fixtures/dashboard-0003.json1
-rw-r--r--tests/schema/fixtures/dashboard-0004.json1
-rw-r--r--tests/schema/fixtures/dashboard-0005.json1
-rw-r--r--tests/schema/fixtures/dashboard-0006.json1
-rw-r--r--tests/schema/fixtures/dashboard-0007.json1
-rw-r--r--tests/schema/fixtures/dashboard-0008.json9
-rw-r--r--tests/schema/fixtures/dashboard-0008.yaml3
-rw-r--r--tests/test_parser.py18
11 files changed, 35 insertions, 3 deletions
diff --git a/grafana_dashboards/schema/dashboard.py b/grafana_dashboards/schema/dashboard.py
index 977c248..bf396d8 100644
--- a/grafana_dashboards/schema/dashboard.py
+++ b/grafana_dashboards/schema/dashboard.py
@@ -21,6 +21,7 @@ class Dashboard(object):
21 21
22 def get_schema(self): 22 def get_schema(self):
23 dashboard = { 23 dashboard = {
24 v.Required('timezone', default='utc'): v.Any('browser', 'utc'),
24 v.Required('title'): v.All(str, v.Length(min=1)), 25 v.Required('title'): v.All(str, v.Length(min=1)),
25 v.Optional('id'): int, 26 v.Optional('id'): int,
26 } 27 }
diff --git a/tests/schema/fixtures/dashboard-0001.json b/tests/schema/fixtures/dashboard-0001.json
index cc98738..688f783 100644
--- a/tests/schema/fixtures/dashboard-0001.json
+++ b/tests/schema/fixtures/dashboard-0001.json
@@ -2,6 +2,7 @@
2 "dashboard": { 2 "dashboard": {
3 "new-dashboard": { 3 "new-dashboard": {
4 "rows": [], 4 "rows": [],
5 "timezone": "utc",
5 "title": "New dashboard" 6 "title": "New dashboard"
6 } 7 }
7 } 8 }
diff --git a/tests/schema/fixtures/dashboard-0002.json b/tests/schema/fixtures/dashboard-0002.json
index 67381e1..c6a0fce 100644
--- a/tests/schema/fixtures/dashboard-0002.json
+++ b/tests/schema/fixtures/dashboard-0002.json
@@ -11,6 +11,7 @@
11 "title": "New row" 11 "title": "New row"
12 } 12 }
13 ], 13 ],
14 "timezone": "utc",
14 "title": "New dashboard" 15 "title": "New dashboard"
15 } 16 }
16 } 17 }
diff --git a/tests/schema/fixtures/dashboard-0003.json b/tests/schema/fixtures/dashboard-0003.json
index 1f30291..d5915d2 100644
--- a/tests/schema/fixtures/dashboard-0003.json
+++ b/tests/schema/fixtures/dashboard-0003.json
@@ -23,6 +23,7 @@
23 "title": "New row" 23 "title": "New row"
24 } 24 }
25 ], 25 ],
26 "timezone": "utc",
26 "title": "New dashboard" 27 "title": "New dashboard"
27 } 28 }
28 } 29 }
diff --git a/tests/schema/fixtures/dashboard-0004.json b/tests/schema/fixtures/dashboard-0004.json
index c28f71d..c1e67b9 100644
--- a/tests/schema/fixtures/dashboard-0004.json
+++ b/tests/schema/fixtures/dashboard-0004.json
@@ -21,6 +21,7 @@
21 "title": "New row" 21 "title": "New row"
22 } 22 }
23 ], 23 ],
24 "timezone": "utc",
24 "title": "New dashboard" 25 "title": "New dashboard"
25 } 26 }
26 } 27 }
diff --git a/tests/schema/fixtures/dashboard-0005.json b/tests/schema/fixtures/dashboard-0005.json
index aa91cf3..2c9d7b2 100644
--- a/tests/schema/fixtures/dashboard-0005.json
+++ b/tests/schema/fixtures/dashboard-0005.json
@@ -31,6 +31,7 @@
31 "title": "New row" 31 "title": "New row"
32 } 32 }
33 ], 33 ],
34 "timezone": "utc",
34 "title": "New dashboard" 35 "title": "New dashboard"
35 } 36 }
36 } 37 }
diff --git a/tests/schema/fixtures/dashboard-0006.json b/tests/schema/fixtures/dashboard-0006.json
index a073347..d72678c 100644
--- a/tests/schema/fixtures/dashboard-0006.json
+++ b/tests/schema/fixtures/dashboard-0006.json
@@ -36,6 +36,7 @@
36 "title": "New row" 36 "title": "New row"
37 } 37 }
38 ], 38 ],
39 "timezone": "utc",
39 "title": "New dashboard" 40 "title": "New dashboard"
40 } 41 }
41 } 42 }
diff --git a/tests/schema/fixtures/dashboard-0007.json b/tests/schema/fixtures/dashboard-0007.json
index 824ec91..4f9e069 100644
--- a/tests/schema/fixtures/dashboard-0007.json
+++ b/tests/schema/fixtures/dashboard-0007.json
@@ -41,6 +41,7 @@
41 "title": "bar" 41 "title": "bar"
42 } 42 }
43 ], 43 ],
44 "timezone": "utc",
44 "title": "New dashboard" 45 "title": "New dashboard"
45 } 46 }
46 } 47 }
diff --git a/tests/schema/fixtures/dashboard-0008.json b/tests/schema/fixtures/dashboard-0008.json
new file mode 100644
index 0000000..77202f7
--- /dev/null
+++ b/tests/schema/fixtures/dashboard-0008.json
@@ -0,0 +1,9 @@
1{
2 "dashboard": {
3 "new-dashboard": {
4 "rows": [],
5 "timezone": "browser",
6 "title": "New dashboard"
7 }
8 }
9}
diff --git a/tests/schema/fixtures/dashboard-0008.yaml b/tests/schema/fixtures/dashboard-0008.yaml
new file mode 100644
index 0000000..b0529c7
--- /dev/null
+++ b/tests/schema/fixtures/dashboard-0008.yaml
@@ -0,0 +1,3 @@
1dashboard:
2 timezone: browser
3 title: New dashboard
diff --git a/tests/test_parser.py b/tests/test_parser.py
index a3824f3..fcb9904 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -33,8 +33,16 @@ class TestCaseParser(TestCase):
33 os.path.dirname(__file__), 'fixtures/parser/dashboard-0001.yaml') 33 os.path.dirname(__file__), 'fixtures/parser/dashboard-0001.yaml')
34 self.parser.parse(path) 34 self.parser.parse(path)
35 dashboard = { 35 dashboard = {
36 'foobar': {'rows': [], 'title': 'foobar'}, 36 'foobar': {
37 'new-dashboard': {'rows': [], 'title': 'New dashboard'}, 37 'rows': [],
38 'timezone': 'utc',
39 'title': 'foobar',
40 },
41 'new-dashboard': {
42 'rows': [],
43 'timezone': 'utc',
44 'title': 'New dashboard',
45 },
38 } 46 }
39 47
40 # Get parsed dashboard 48 # Get parsed dashboard
@@ -61,7 +69,11 @@ class TestCaseParser(TestCase):
61 os.path.dirname(__file__), 'fixtures/parser/dashboard-0001.yaml') 69 os.path.dirname(__file__), 'fixtures/parser/dashboard-0001.yaml')
62 self.parser.parse(path) 70 self.parser.parse(path)
63 dashboard = { 71 dashboard = {
64 'new-dashboard': {'rows': [], 'title': 'New dashboard'}, 72 'new-dashboard': {
73 'rows': [],
74 'timezone': 'utc',
75 'title': 'New dashboard',
76 },
65 } 77 }
66 78
67 # Get parsed dashboard 79 # Get parsed dashboard