Skip to content

Commit 6d2ebc6

Browse files
committed
Fix get_bytes and add a test. Closes #3
1 parent 12b1cec commit 6d2ebc6

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

quickchart/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def get_short_url(self):
6666

6767
def get_bytes(self):
6868
resp = self._post('https://quickchart.io/chart')
69-
return response.content
69+
return resp.content
7070

7171
def to_file(self, path):
7272
content = self.get_bytes()

tests.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,21 @@ def test_no_chart(self):
3333

3434
self.assertRaises(RuntimeError, qc.get_url)
3535

36+
def test_get_bytes(self):
37+
qc = QuickChart()
38+
qc.width = 600
39+
qc.height = 300
40+
qc.config = {
41+
"type": "bar",
42+
"data": {
43+
"labels": ["Hello world", "Test"],
44+
"datasets": [{
45+
"label": "Foo",
46+
"data": [1, 2]
47+
}]
48+
}
49+
}
50+
self.assertTrue(len(qc.get_bytes()) > 8000)
51+
3652
if __name__ == '__main__':
3753
unittest.main()

0 commit comments

Comments
 (0)