summaryrefslogtreecommitdiff
path: root/test_tablib.py
diff options
context:
space:
mode:
authorBruno Soares <brunomsss@gmail.com>2018-09-12 15:49:46 -0300
committerIuri de Silvio <iurisilvio@gmail.com>2018-09-12 15:49:46 -0300
commit3d5943a8a43a721bea1f3e33dc669a581a095c53 (patch)
tree3da30935c5803328f45e4cdaf4fd27a9e996a5e5 /test_tablib.py
parent38486231cc4dc46d1ff055a38fe7c236cbe5c8aa (diff)
downloadtablib-3d5943a8a43a721bea1f3e33dc669a581a095c53.tar.gz
Fix: Circular reference detected error (#332)
* Rename function name * Add uuid handler on json dumps * Add myself to authors
Diffstat (limited to 'test_tablib.py')
-rwxr-xr-xtest_tablib.py17
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."""