[extensions-web] extensions: Add a test for invalid JSON metadata



commit 49391c43e21dff2ddeff931ccffc7f341ed22811
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sat Mar 3 05:33:53 2012 -0500

    extensions: Add a test for invalid JSON metadata

 .../testdata/BadMetadata/BadMetadata.zip           |  Bin 0 -> 194 bytes
 .../extensions/testdata/BadMetadata/metadata.json  |    1 +
 sweettooth/extensions/tests.py                     |    5 +++++
 3 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/sweettooth/extensions/testdata/BadMetadata/BadMetadata.zip b/sweettooth/extensions/testdata/BadMetadata/BadMetadata.zip
new file mode 100644
index 0000000..5d3515f
Binary files /dev/null and b/sweettooth/extensions/testdata/BadMetadata/BadMetadata.zip differ
diff --git a/sweettooth/extensions/testdata/BadMetadata/metadata.json b/sweettooth/extensions/testdata/BadMetadata/metadata.json
new file mode 100644
index 0000000..fd0a53a
--- /dev/null
+++ b/sweettooth/extensions/testdata/BadMetadata/metadata.json
@@ -0,0 +1 @@
+This is not JSON!
diff --git a/sweettooth/extensions/tests.py b/sweettooth/extensions/tests.py
index 76b1083..4f1e77a 100644
--- a/sweettooth/extensions/tests.py
+++ b/sweettooth/extensions/tests.py
@@ -84,6 +84,11 @@ class ParseZipfileTest(BasicUserTestCase, TestCase):
                 models.parse_zipfile_metadata(f)
             self.assertEquals(cm.exception.message, "Missing metadata.json")
 
+        with get_test_zipfile('BadMetadata') as f:
+            with self.assertRaises(models.InvalidExtensionData) as cm:
+                models.parse_zipfile_metadata(f)
+            self.assertEquals(cm.exception.message, "Invalid JSON data")
+
 class ReplaceMetadataTest(BasicUserTestCase, TestCase):
     @expectedFailure
     def test_replace_metadata(self):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]