Skip to content

Commit affb9f1

Browse files
author
Brian Luft
committed
adds test for add_bars
1 parent cf3047b commit affb9f1

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

pyflot/__init__.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import collections
2-
32
from functools import partial
43
from itertools import chain
54
import inspect
@@ -58,7 +57,6 @@ def __init__(self):
5857
if hasattr(base, 'options'):
5958
update(self._options, base.options)
6059

61-
6260
@property
6361
def series_json(self):
6462
"""
@@ -77,10 +75,14 @@ def options_json(self):
7775
"""
7876
return json.dumps(self._options)
7977

80-
#add_bars
81-
#add_line
82-
#add_points
8378
def __getattr__(self, value):
79+
"""
80+
add_bars
81+
add_line
82+
add_points
83+
84+
provides shortcut methods for adding series using a particular line type
85+
"""
8486
if value.startswith('add_'):
8587
return partial(self.add_series_type, value[4:])
8688

tests/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ def test_add_time_series(self):
9999
self.assertEqual(self.flot._options['xaxis'],
100100
{'mode': 'time'})
101101

102+
def test_add_bars(self):
103+
"test the shortcut for adding a series as bars"
104+
series = {'data': ((0,0), ) + S1,
105+
"bars": {"barWidth": 0.75, "show": True}}
106+
self.flot.add_bars(((0,0), ) + S1)
107+
self.assertEqual(self.flot._series[0]['bars'], {'show': True})
108+
self.assertEqual(json.dumps([series]), self.flot.series_json)
109+
102110
def test_empty_options_json(self):
103111
"make sure conversion to JSON works for default options"
104112
self.assertEqual("{}", self.flot.options_json)

0 commit comments

Comments
 (0)