/+junk/pygooglechart-py3k

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/%2Bjunk/pygooglechart-py3k

« back to all changes in this revision

Viewing changes to test/test.py

  • Committer: gak
  • Date: 2008-08-23 08:24:07 UTC
  • Revision ID: git-v1:62a852b162ce05f4126ffc3c7c594d06c8d6f5dc

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
sys.path.insert(0, ROOT)
12
12
 
13
13
import pygooglechart as gc
 
14
from pygooglechart import NoDataGivenException
14
15
 
15
16
 
16
17
class TestBase(unittest.TestCase):
23
24
        self.temp_image = 'temp.png'
24
25
 
25
26
    def tearDown(self):
26
 
        if os.path.exists(self.temp_image):
 
27
        if os.exists(self.temp_image):
27
28
            os.unlink(self.temp_image)
28
29
 
29
30
    def raise_warnings(self, rw):
141
142
 
142
143
    def test_no_data(self):
143
144
        chart = gc.QRChart(100, 100)
144
 
        self.assertRaises(gc.NoDataGivenException, chart.get_url)
 
145
        self.assertRaises(NoDataGivenException, chart.get_url)
145
146
 
146
147
    def test_validate_image(self):
147
148
        text = 'Hello World'
157
158
        chart.set_ec('H', 0)
158
159
        self.assertQRImage(chart, text)
159
160
 
 
161
    def test_validate_shift_jis(self):
 
162
        # XXX: It looks like PyQrcodec doesn't do shift_jis?
 
163
        text = unicode('こんにちは世界', 'utf-8').encode('shift_jis')
 
164
        chart = gc.QRChart(100, 100)
 
165
        chart.add_data(text)
 
166
        chart.set_ec('H', 0)
 
167
        chart.set_encoding('Shift_JIS')
 
168
        self.assertChartURL(chart.get_url(), \
 
169
            '?cht=qr&chs=100x100&chl=%82%B1%82%F1%82%C9' \
 
170
            '%82%BF%82%CD%90%A2%8AE&choe=Shift_JIS&chld=H|0')
 
171
        chart.download(self.temp_image)
 
172
 
 
173
 
160
174
class TestGrammar(TestBase):
161
175
 
162
176
    types = ('Venn', 'GroupedHorizontalBar', 'GoogleOMeter', 'Scatter',