summaryrefslogtreecommitdiff
path: root/test_tablib.py
diff options
context:
space:
mode:
authorKenneth Reitz <me@kennethreitz.com>2010-09-25 18:03:03 -0400
committerKenneth Reitz <me@kennethreitz.com>2010-09-25 18:03:03 -0400
commit3fc898e222c6215c46711d36677f70b8df33eca3 (patch)
tree50a3395a186fc6d9e0f84e046a23b3362112b5fc /test_tablib.py
parentde46f45e2e13d0f689d895236c6bdcb0656593b2 (diff)
downloadtablib-3fc898e222c6215c46711d36677f70b8df33eca3.tar.gz
Auto-detectors operational.
Diffstat (limited to 'test_tablib.py')
-rwxr-xr-xtest_tablib.py37
1 files changed, 35 insertions, 2 deletions
diff --git a/test_tablib.py b/test_tablib.py
index e50b767..1091390 100755
--- a/test_tablib.py
+++ b/test_tablib.py
@@ -262,9 +262,42 @@ class TablibTestCase(unittest.TestCase):
self.assertEqual(_csv, data.csv)
def test_csv_format_detect(self):
- """Test format detection."""
+ """Test CSV format detection."""
- pass
+ _csv = (
+ '1,2,3\n'
+ '4,5,6\n'
+ '7,8,9\n'
+ )
+ _bunk = (
+ '¡¡¡¡¡¡¡¡£™∞¢£§∞§¶•¶ª∞¶•ªº••ª–º§•†•§º¶•†¥ª–º•§ƒø¥¨©πƒø†ˆ¥ç©¨√øˆ¥≈†ƒ¥ç©ø¨çˆ¥ƒçø¶'
+ )
+
+ self.assertTrue(tablib.formats.csv.detect(_csv))
+ self.assertFalse(tablib.formats.csv.detect(_bunk))
+
+ def test_json_format_detect(self):
+ """Test JSON format detection."""
+
+ _json = '[{"last_name": "Adams","age": 90,"first_name": "John"}]'
+ _bunk = (
+ '¡¡¡¡¡¡¡¡£™∞¢£§∞§¶•¶ª∞¶•ªº••ª–º§•†•§º¶•†¥ª–º•§ƒø¥¨©πƒø†ˆ¥ç©¨√øˆ¥≈†ƒ¥ç©ø¨çˆ¥ƒçø¶'
+ )
+
+ self.assertTrue(tablib.formats.json.detect(_json))
+ self.assertFalse(tablib.formats.json.detect(_bunk))
+
+
+ def test_yaml_format_detect(self):
+ """Test YAML format detection."""
+
+ _yaml = '- {age: 90, first_name: John, last_name: Adams}'
+ _bunk = (
+ '¡¡¡¡¡¡---///\n\n\n¡¡£™∞¢£§∞§¶•¶ª∞¶•ªº••ª–º§•†•§º¶•†¥ª–º•§ƒø¥¨©πƒø†ˆ¥ç©¨√øˆ¥≈†ƒ¥ç©ø¨çˆ¥ƒçø¶'
+ )
+
+ self.assertTrue(tablib.formats.yaml.detect(_yaml))
+ self.assertFalse(tablib.formats.yaml.detect(_bunk))
def test_wipe(self):