90
98
self.assertRaises(UserWarning, sv, 30, [0, 1])
101
class TestChartQR(TestBase):
103
def assertQRImage(self, chart, text):
107
print 'PyQrCodec not installed. Can not test QR code image'
112
status, string = PyQrcodec.decode(fn)
113
self.assertTrue(status)
114
self.assertEquals(text, string)
116
def test_simple(self):
118
chart = gc.QRChart(100, 150)
120
self.assertChartURL(chart.get_url(), \
121
'?cht=qr&chs=100x150&chl=Hello%20World')
123
def test_encoding(self):
124
chart = gc.QRChart(100, 100)
125
chart.add_data('Hello World')
126
self.assertChartURL(chart.get_url(), \
127
'?cht=qr&chs=100x100&chl=Hello%20World')
129
def test_no_data(self):
130
chart = gc.QRChart(100, 100)
131
self.assertRaises(NoDataGivenException, chart.get_url)
133
def test_validate_image(self):
135
chart = gc.QRChart(100, 100)
137
chart.set_ec('H', 0) # PyQrcodec seems to only work on higher EC
138
self.assertQRImage(chart, text)
140
def test_validate_utf8(self):
141
text = 'こんにちは世界' # Hello world in Japanese UTF8
142
chart = gc.QRChart(100, 100)
145
self.assertQRImage(chart, text)
147
def test_validate_shift_jis(self):
148
# XXX: It looks like PyQrcodec doesn't do shift_jis?
149
text = unicode('こんにちは世界', 'utf-8').encode('shift_jis')
150
chart = gc.QRChart(100, 100)
153
chart.set_encoding('Shift_JIS')
154
self.assertChartURL(chart.get_url(), \
155
'?cht=qr&chs=100x100&chl=%82%B1%82%F1%82%C9' \
156
'%82%BF%82%CD%90%A2%8AE&choe=Shift_JIS&chld=H|0')
157
chart.download('temp.png')
93
160
class TestGrammar(TestBase):
95
162
types = ('Venn', 'GroupedHorizontalBar', 'GoogleOMeter', 'Scatter',
96
163
'StackedVerticalBar', 'Map', 'StackedHorizontalBar', 'SimpleLine',
97
'SparkLine', 'GroupedVerticalBar', 'SplineRadar', 'XYLine', 'Radar')
164
'SparkLine', 'GroupedVerticalBar', 'SplineRadar', 'XYLine', 'Radar',
99
167
def test_chart_types(self):
100
168
ret = gc.ChartGrammar.get_possible_chart_types()