diff options
| author | Kenneth Reitz <me@kennethreitz.com> | 2010-09-25 18:03:03 -0400 |
|---|---|---|
| committer | Kenneth Reitz <me@kennethreitz.com> | 2010-10-01 17:52:08 -0400 |
| commit | eaa4de779391d9cbfc970cd418ccb36efdde122e (patch) | |
| tree | dc58128651c5ce4c43a6df37b96fb08b38698cc8 /test_tablib.py | |
| parent | d479c5735ad5875fc2a953abd1c20654ddc83aef (diff) | |
| download | tablib-eaa4de779391d9cbfc970cd418ccb36efdde122e.tar.gz | |
Auto-detectors operational.
Diffstat (limited to 'test_tablib.py')
| -rwxr-xr-x | test_tablib.py | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/test_tablib.py b/test_tablib.py index 9c1941e..3f8ee37 100755 --- a/test_tablib.py +++ b/test_tablib.py @@ -269,9 +269,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): |
