[extensions-web] extensions: Add more tests for shell versions
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] extensions: Add more tests for shell versions
- Date: Sat, 3 Mar 2012 11:16:55 +0000 (UTC)
commit 49e5d8db8a02022ccc1df8794bfd7fc54d79de14
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Sat Mar 3 05:40:46 2012 -0500
extensions: Add more tests for shell versions
This improves our coverage considerably.
sweettooth/extensions/tests.py | 32 ++++++++++++++++++++++++++++++--
1 files changed, 30 insertions(+), 2 deletions(-)
---
diff --git a/sweettooth/extensions/tests.py b/sweettooth/extensions/tests.py
index 4f1e77a..8e6637c 100644
--- a/sweettooth/extensions/tests.py
+++ b/sweettooth/extensions/tests.py
@@ -266,22 +266,50 @@ class ExtensionVersionTest(BasicUserTestCase, TestCase):
self.assertEquals(shell_versions, ["3.0", "3.2"])
class ShellVersionTest(TestCase):
- def test_shell_version_parsing_basic(self):
+ def test_shell_version_parsing(self):
lookup_version = models.ShellVersion.objects.lookup_for_version_string
get_version = models.ShellVersion.objects.get_for_version_string
+ # Make sure we don't create a new version
+ self.assertEquals(lookup_version("3.0.0"), None)
version = get_version("3.0.0")
+ self.assertEquals(lookup_version("3.0.0"), version)
self.assertEquals(version.major, 3)
self.assertEquals(version.minor, 0)
self.assertEquals(version.point, 0)
+ self.assertEquals(lookup_version("3.2"), None)
version = get_version("3.2")
+ self.assertEquals(lookup_version("3.2"), version)
self.assertEquals(version.major, 3)
self.assertEquals(version.minor, 2)
self.assertEquals(version.point, -1)
with self.assertRaises(models.InvalidShellVersion):
- version = get_version("3.1")
+ get_version("3.1")
+ lookup_version("3.1")
+
+ def test_bad_shell_versions(self):
+ with self.assertRaises(models.InvalidShellVersion):
+ models.parse_version_string("3", ignore_micro=False)
+
+ with self.assertRaises(models.InvalidShellVersion):
+ models.parse_version_string("3.2.2.2.1", ignore_micro=False)
+
+ with self.assertRaises(models.InvalidShellVersion):
+ models.parse_version_string("a.b", ignore_micro=False)
+
+ with self.assertRaises(models.InvalidShellVersion):
+ models.parse_version_string("3.2.a", ignore_micro=False)
+
+ def test_ignore_micro(self):
+ with self.assertRaises(models.InvalidShellVersion):
+ models.parse_version_string("4.3.2.1", ignore_micro=False)
+
+ major, minor, point = models.parse_version_string("4.3.2.1", ignore_micro=True)
+ self.assertEquals(major, 4)
+ self.assertEquals(minor, 3)
+ self.assertEquals(point, 2)
class UpdateVersionTest(TestCase):
fixtures = [os.path.join(testdata_dir, 'test_upgrade_data.json')]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]