71
85
self.assertEquals(sv(2222, [0, 10000]), 22.22)
73
87
self.raise_warnings(True)
75
# self.assertRaises(UserWarning, sv, -10, [0, 1])
76
# self.assertEquals(UserWarning, sv, 30, [0, 1])
88
self.assertRaises(UserWarning, sv, -10, [0, 1])
89
self.assertRaises(UserWarning, sv, 30, [0, 1])
78
91
def test_ext_scale(self):
79
92
sv = gc.ExtendedData.scale_value
89
102
self.assertRaises(UserWarning, sv, -10, [0, 1])
90
103
self.assertRaises(UserWarning, sv, 30, [0, 1])
106
class TestLineChart(TestBase):
108
def test_none_data(self):
109
chart = gc.SimpleLineChart(300, 100)
110
chart.add_data([1, 2, 3, None, 5])
111
self.assertChartURL(chart.get_url(), \
112
'?cht=lc&chs=300x100&chd=e:AAMzZm__zM')
115
class TestQRChart(TestBase):
117
def assertQRImage(self, chart, text):
121
print 'PyQrCodec not installed. Can not test QR code image'
124
chart.download(self.temp_image)
125
status, string = PyQrcodec.decode(self.temp_image)
126
self.assertTrue(status)
127
self.assertEquals(text, string)
129
def test_simple(self):
131
chart = gc.QRChart(100, 150)
133
self.assertChartURL(chart.get_url(), \
134
'?cht=qr&chs=100x150&chl=Hello%20World')
136
def test_encoding(self):
137
chart = gc.QRChart(100, 100)
138
chart.add_data('Hello World')
139
self.assertChartURL(chart.get_url(), \
140
'?cht=qr&chs=100x100&chl=Hello%20World')
142
def test_no_data(self):
143
chart = gc.QRChart(100, 100)
144
self.assertRaises(gc.NoDataGivenException, chart.get_url)
146
def test_validate_image(self):
148
chart = gc.QRChart(100, 100)
150
chart.set_ec('H', 0) # PyQrcodec seems to only work on higher EC
151
self.assertQRImage(chart, text)
153
def test_validate_utf8(self):
154
text = 'こんにちは世界' # Hello world in Japanese UTF-8
155
chart = gc.QRChart(100, 100)
158
self.assertQRImage(chart, text)
92
160
class TestGrammar(TestBase):
94
162
types = ('Venn', 'GroupedHorizontalBar', 'GoogleOMeter', 'Scatter',
95
163
'StackedVerticalBar', 'Map', 'StackedHorizontalBar', 'SimpleLine',
96
'SparkLine', 'GroupedVerticalBar', 'SplineRadar', 'XYLine', 'Radar')
164
'SparkLine', 'GroupedVerticalBar', 'SplineRadar', 'XYLine', 'Radar',
98
167
def test_chart_types(self):
99
168
ret = gc.ChartGrammar.get_possible_chart_types()