summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-11-19 22:05:17 +0000
committerGerrit Code Review <review@openstack.org>2015-11-19 22:05:17 +0000
commitfd09f80b1effb006698ddd7fdb327662c73d211f (patch)
tree37ccb548d1ac23a9ef56a30bd3f54b1f9b6c770a
parentd1135dea79778185c83c644e25ad1fc4abebf364 (diff)
parent3b5ba508f774daa0386af1fd1b608d517a5bf3b0 (diff)
Merge "Add unit test coverage for panels"0.0.4
-rw-r--r--grafana_dashboards/schema/panel/singlestat.py2
-rw-r--r--tests/schema/panels/__init__.py0
-rw-r--r--tests/schema/panels/test_base.py35
-rw-r--r--tests/schema/panels/test_dashlist.py39
-rw-r--r--tests/schema/panels/test_graph.py47
-rw-r--r--tests/schema/panels/test_singlestat.py52
-rw-r--r--tests/schema/panels/test_text.py37
7 files changed, 211 insertions, 1 deletions
diff --git a/grafana_dashboards/schema/panel/singlestat.py b/grafana_dashboards/schema/panel/singlestat.py
index cd0e202..5accc18 100644
--- a/grafana_dashboards/schema/panel/singlestat.py
+++ b/grafana_dashboards/schema/panel/singlestat.py
@@ -60,7 +60,7 @@ class Singlestat(Base):
60 v.Required( 60 v.Required(
61 'valueFontSize', default='80%'): v.All( 61 'valueFontSize', default='80%'): v.All(
62 v.Match(r'^[1-9]?[0]{1}%$|^1[0-9]?[0]{1}%$|^200%$')), 62 v.Match(r'^[1-9]?[0]{1}%$|^1[0-9]?[0]{1}%$|^200%$')),
63 v.Required('valueName', default='avg'): v.All( 63 v.Required('valueName', default='avg'): v.Any(
64 'avg', 'current', 'max', 'min', 'total'), 64 'avg', 'current', 'max', 'min', 'total'),
65 v.Optional('decimals'): v.All(int, v.Range(min=0, max=12)), 65 v.Optional('decimals'): v.All(int, v.Range(min=0, max=12)),
66 } 66 }
diff --git a/tests/schema/panels/__init__.py b/tests/schema/panels/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/schema/panels/__init__.py
diff --git a/tests/schema/panels/test_base.py b/tests/schema/panels/test_base.py
new file mode 100644
index 0000000..420fab6
--- /dev/null
+++ b/tests/schema/panels/test_base.py
@@ -0,0 +1,35 @@
1# Copyright 2015 Red Hat, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from testtools import TestCase
16
17from grafana_dashboards.schema.panel.base import Base
18
19
20class TestCaseBase(TestCase):
21
22 def setUp(self):
23 super(TestCaseBase, self).setUp()
24 self.schema = Base().get_schema()
25
26 def test_defaults(self):
27 # Ensure default values get parsed correctly.
28 defaults = {
29 'editable': True,
30 'error': False,
31 'span': 12,
32 'title': 'foobar',
33 'type': 'text',
34 }
35 self.assertEqual(self.schema(defaults), defaults)
diff --git a/tests/schema/panels/test_dashlist.py b/tests/schema/panels/test_dashlist.py
new file mode 100644
index 0000000..953f3ad
--- /dev/null
+++ b/tests/schema/panels/test_dashlist.py
@@ -0,0 +1,39 @@
1# Copyright 2015 Red Hat, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from testtools import TestCase
16
17from grafana_dashboards.schema.panel.dashlist import Dashlist
18
19
20class TestCaseDashlist(TestCase):
21
22 def setUp(self):
23 super(TestCaseDashlist, self).setUp()
24 self.schema = Dashlist().get_schema()
25
26 def test_defaults(self):
27 # Ensure default values get parsed correctly.
28 defaults = {
29 'editable': True,
30 'error': False,
31 'limit': 10,
32 'mode': 'starred',
33 'query': '',
34 'span': 12,
35 'tag': '',
36 'title': 'foobar',
37 'type': 'dashlist',
38 }
39 self.assertEqual(self.schema(defaults), defaults)
diff --git a/tests/schema/panels/test_graph.py b/tests/schema/panels/test_graph.py
new file mode 100644
index 0000000..a54e11f
--- /dev/null
+++ b/tests/schema/panels/test_graph.py
@@ -0,0 +1,47 @@
1# Copyright 2015 Red Hat, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from testtools import TestCase
16
17from grafana_dashboards.schema.panel.graph import Graph
18
19
20class TestCaseGraph(TestCase):
21
22 def setUp(self):
23 super(TestCaseGraph, self).setUp()
24 self.schema = Graph().get_schema()
25
26 def test_defaults(self):
27 # Ensure default values get parsed correctly.
28 defaults = {
29 'bars': False,
30 'editable': True,
31 'error': False,
32 'fill': 1,
33 'lines': True,
34 'linewidth': 2,
35 'percentage': False,
36 'pointradius': 5,
37 'points': False,
38 'span': 12,
39 'stack': False,
40 'steppedLine': False,
41 'targets': [],
42 'title': 'foobar',
43 'type': 'graph',
44 'x-axis': True,
45 'y-axis': True,
46 }
47 self.assertEqual(self.schema(defaults), defaults)
diff --git a/tests/schema/panels/test_singlestat.py b/tests/schema/panels/test_singlestat.py
new file mode 100644
index 0000000..01fd019
--- /dev/null
+++ b/tests/schema/panels/test_singlestat.py
@@ -0,0 +1,52 @@
1# Copyright 2015 Red Hat, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from testtools import TestCase
16
17from grafana_dashboards.schema.panel.singlestat import Singlestat
18
19
20class TestCaseSinglestat(TestCase):
21
22 def setUp(self):
23 super(TestCaseSinglestat, self).setUp()
24 self.schema = Singlestat().get_schema()
25
26 def test_defaults(self):
27 # Ensure default values get parsed correctly.
28 defaults = {
29 'colorBackground': False,
30 'colorValue': False,
31 'editable': True,
32 'error': False,
33 'maxDataPoints': 100,
34 'postfix': '',
35 'postfixFontSize': '50%',
36 'prefix': '',
37 'prefixFontSize': '50%',
38 'span': 12,
39 'sparkline': {
40 'fillColor': 'rgba(31, 118, 189, 0.18)',
41 'full': False,
42 'lineColor': 'rgb(31, 120, 193)',
43 'show': False
44 },
45 'targets': [],
46 'thresholds': '',
47 'title': 'foobar',
48 'type': 'singlestat',
49 'valueFontSize': '80%',
50 'valueName': 'avg',
51 }
52 self.assertEqual(self.schema(defaults), defaults)
diff --git a/tests/schema/panels/test_text.py b/tests/schema/panels/test_text.py
new file mode 100644
index 0000000..73abea2
--- /dev/null
+++ b/tests/schema/panels/test_text.py
@@ -0,0 +1,37 @@
1# Copyright 2015 Red Hat, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from testtools import TestCase
16
17from grafana_dashboards.schema.panel.text import Text
18
19
20class TestCaseText(TestCase):
21
22 def setUp(self):
23 super(TestCaseText, self).setUp()
24 self.schema = Text().get_schema()
25
26 def test_defaults(self):
27 # Ensure default values get parsed correctly.
28 defaults = {
29 'content': 'junk',
30 'editable': True,
31 'error': False,
32 'mode': 'markdown',
33 'span': 12,
34 'title': 'foobar',
35 'type': 'text',
36 }
37 self.assertEqual(self.schema(defaults), defaults)