diff options
Diffstat (limited to 'test_tablib.py')
| -rwxr-xr-x | test_tablib.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test_tablib.py b/test_tablib.py index 84cc46a..b945a2d 100755 --- a/test_tablib.py +++ b/test_tablib.py @@ -6,6 +6,7 @@ import doctest import json import unittest import sys +from uuid import uuid4 import datetime @@ -226,6 +227,22 @@ class TablibTestCase(unittest.TestCase): # Delete from invalid index self.assertRaises(IndexError, self.founders.__delitem__, 3) + + def test_json_export(self): + """Verify exporting dataset object as JSON""" + + address_id = uuid4() + headers = self.headers + ('address_id',) + founders = tablib.Dataset(headers=headers, title='Founders') + founders.append(('John', 'Adams', 90, address_id)) + founders_json = founders.export('json') + + expected_json = ( + '[{"first_name": "John", "last_name": "Adams", "gpa": 90, ' + '"address_id": "%s"}]' % str(address_id) + ) + + self.assertEqual(founders_json, expected_json) def test_csv_export(self): """Verify exporting dataset object as CSV.""" |
