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

[tor-commits] [bridgedb/master] Add unittests for bridgedb.parse.versions module.



commit ab99f855f708dec213c9eea1489643c01526e0b0
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date:   Thu Aug 21 04:47:54 2014 +0000

    Add unittests for bridgedb.parse.versions module.
---
 lib/bridgedb/test/test_parse_versions.py |   42 ++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/lib/bridgedb/test/test_parse_versions.py b/lib/bridgedb/test/test_parse_versions.py
new file mode 100644
index 0000000..3b2e392
--- /dev/null
+++ b/lib/bridgedb/test/test_parse_versions.py
@@ -0,0 +1,42 @@
+# -*- coding: utf-8 -*-
+#_____________________________________________________________________________
+#
+# This file is part of BridgeDB, a Tor bridge distribution system.
+#
+# :authors: Isis Lovecruft 0xA3ADB67A2CDB8B35 <isis@xxxxxxxxxxxxxx>
+#           please also see AUTHORS file
+# :copyright: (c) 2014, The Tor Project, Inc.
+#             (c) 2014, Isis Lovecruft
+# :license: see LICENSE for licensing information
+#_____________________________________________________________________________
+
+"""Unittests for :mod:`bridgedb.parse.versions`."""
+
+
+from __future__ import print_function
+
+from twisted.trial import unittest
+
+from bridgedb.parse import versions
+
+
+class ParseVersionTests(unittest.TestCase):
+    """Unitests for :class:`bridgedb.parse.versions.Version`."""
+
+    def test_Version_with_bad_delimiter(self):
+        """Test parsing a version number which uses '-' as a delimiter."""
+        self.assertRaises(versions.InvalidVersionStringFormat,
+                          versions.Version, '2-6-0', package='tor')
+
+    def test_Version_really_long_version_string(self):
+        """Parsing a version number which is way too long should raise
+        an IndexError which is ignored.
+        """
+        v = versions.Version('2.6.0.0.beta', package='tor')
+        self.assertEqual(v.prerelease, 'beta')
+        self.assertEqual(v.major, 6)
+
+    def test_Version_string(self):
+        """Test converting a valid Version object into string form."""
+        v = versions.Version('0.2.5.4', package='tor')
+        self.assertEqual(v.base(), '0.2.5.4')



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits