[extensions-web] extensions: Add test for first_line_of_description
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] extensions: Add test for first_line_of_description
- Date: Sat, 3 Mar 2012 11:17:05 +0000 (UTC)
commit c8f36787c28b6415ff62797e2364508dfb352e62
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Sat Mar 3 06:08:17 2012 -0500
extensions: Add test for first_line_of_description
sweettooth/extensions/models.py | 1 +
sweettooth/extensions/tests.py | 23 +++++++++++++++++++++++
2 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/sweettooth/extensions/models.py b/sweettooth/extensions/models.py
index 2ad2b39..1574e1b 100644
--- a/sweettooth/extensions/models.py
+++ b/sweettooth/extensions/models.py
@@ -119,6 +119,7 @@ class Extension(models.Model):
return True
return False
+ @property
def first_line_of_description(self):
if not self.description:
return ""
diff --git a/sweettooth/extensions/tests.py b/sweettooth/extensions/tests.py
index ac36015..c36cbf5 100644
--- a/sweettooth/extensions/tests.py
+++ b/sweettooth/extensions/tests.py
@@ -46,6 +46,29 @@ class UUIDPolicyTest(TestCase):
self.assertTrue(models.validate_uuid("bar i-love-gnome org"))
+class ExtensionPropertiesTest(BasicUserTestCase, TestCase):
+ def test_description_parsing(self):
+ metadata = {"uuid": "test-metadata mecheye net",
+ "name": "Test Metadata",
+ "description": "Simple test metadata"}
+
+ extension = models.Extension.objects.create_from_metadata(metadata, creator=self.user)
+ self.assertEquals(extension.first_line_of_description, "Simple test metadata")
+
+ metadata = {"uuid": "test-metadata-2 mecheye net",
+ "name": "Test Metadata",
+ "description": "First line\n\Second line"}
+
+ extension = models.Extension.objects.create_from_metadata(metadata, creator=self.user)
+ self.assertEquals(extension.first_line_of_description, "First line")
+
+ metadata = {"uuid": "test-metadata-3 mecheye net",
+ "name": "Test Metadata",
+ "description": ""}
+
+ extension = models.Extension.objects.create_from_metadata(metadata, creator=self.user)
+ self.assertEquals(extension.first_line_of_description, "")
+
class ParseZipfileTest(BasicUserTestCase, TestCase):
def test_simple_metadata(self):
metadata = {"uuid": "test-metadata mecheye net",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]