[extensions-web] extensions: Fix the handling of bad shell versions
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] extensions: Fix the handling of bad shell versions
- Date: Sat, 3 Mar 2012 02:46:36 +0000 (UTC)
commit 7d435756bf8ce542c2fbc274108ebf8abfeb6356
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Fri Mar 2 21:37:18 2012 -0500
extensions: Fix the handling of bad shell versions
Add a test, as well
sweettooth/extensions/models.py | 6 +++---
.../testdata/BadShellVersion/BadShellVersion.zip | Bin 0 -> 310 bytes
.../testdata/BadShellVersion/metadata.json | 7 +++++++
sweettooth/extensions/tests.py | 7 +++++--
4 files changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/sweettooth/extensions/models.py b/sweettooth/extensions/models.py
index 179cc24..8b9d842 100644
--- a/sweettooth/extensions/models.py
+++ b/sweettooth/extensions/models.py
@@ -384,9 +384,9 @@ class ExtensionVersion(models.Model):
except InvalidShellVersion:
# For now, ignore invalid shell versions, rather than
# causing a fit.
- pass
-
- self.shell_versions.add(sv)
+ continue
+ else:
+ self.shell_versions.add(sv)
def get_status_class(self):
return STATUSES[self.status].lower()
diff --git a/sweettooth/extensions/testdata/BadShellVersion/BadShellVersion.zip b/sweettooth/extensions/testdata/BadShellVersion/BadShellVersion.zip
new file mode 100644
index 0000000..3d29258
Binary files /dev/null and b/sweettooth/extensions/testdata/BadShellVersion/BadShellVersion.zip differ
diff --git a/sweettooth/extensions/testdata/BadShellVersion/metadata.json b/sweettooth/extensions/testdata/BadShellVersion/metadata.json
new file mode 100644
index 0000000..4b8e726
--- /dev/null
+++ b/sweettooth/extensions/testdata/BadShellVersion/metadata.json
@@ -0,0 +1,7 @@
+{
+ "uuid": "bad-shell-version mecheye net",
+ "name": "Bad shell-version test",
+ "description": "Simple test metadata",
+ "url": "http://test-metadata.gnome.org",
+ "shell-version": ["3.2.2.1"]
+}
diff --git a/sweettooth/extensions/tests.py b/sweettooth/extensions/tests.py
index 08c9757..b9cb5ac 100644
--- a/sweettooth/extensions/tests.py
+++ b/sweettooth/extensions/tests.py
@@ -139,8 +139,6 @@ class UploadTest(BasicUserTestCase, TestCase):
self.assertEquals(version2.status, models.STATUS_NEW)
self.assertEquals(version2.version, version1.version+1)
-
-
def test_upload_large_uuid(self):
self.upload_file('LargeUUID')
@@ -154,6 +152,11 @@ class UploadTest(BasicUserTestCase, TestCase):
self.assertEquals(extension.description, "Simple test metadata")
self.assertEquals(extension.url, "http://test-metadata.gnome.org")
+ def test_upload_bad_shell_version(self):
+ response = self.upload_file('BadShellVersion')
+ extension = models.Extension.objects.get(uuid="bad-shell-version mecheye net")
+ version1 = extension.versions.order_by("-version")[0]
+ self.assertIsNotNone(version1.source)
class ExtensionVersionTest(BasicUserTestCase, TestCase):
def test_single_version(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]