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

[tor-commits] [bridgedb/develop] Add unittests for bridgedb.parse.nickname.



commit 35a51c29eafaa6af69abeaacd36f1b90d90e67cd
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date:   Wed Feb 18 21:59:14 2015 +0000

    Add unittests for bridgedb.parse.nickname.
---
 lib/bridgedb/test/test_parse_nickname.py |   63 ++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/lib/bridgedb/test/test_parse_nickname.py b/lib/bridgedb/test/test_parse_nickname.py
new file mode 100644
index 0000000..fea000a
--- /dev/null
+++ b/lib/bridgedb/test/test_parse_nickname.py
@@ -0,0 +1,63 @@
+# -*- coding: utf-8 -*-
+#
+# This file is part of BridgeDB, a Tor bridge distribution system.
+#
+# :authors: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
+#           please also see AUTHORS file
+# :copyright: (c) 2007-2015, The Tor Project, Inc.
+#             (c) 2007-2015, all entities within the AUTHORS file
+#             (c) 2013-2015, Isis Lovecruft
+# :license: see LICENSE for licensing information
+
+"""Unittests for the :mod:`bridgedb.parse.nickname` module."""
+
+from twisted.trial import unittest
+
+from bridgedb.parse.nickname import isValidRouterNickname
+
+
+class IsValidRouterNicknameTests(unittest.TestCase):
+    """Unittests for :func:`bridgedb.parse.nickname.isValidRouterNickname`."""
+
+    def test_parse_nickname_isValidRouterNickname_valid(self):
+        """isValidRouterNickname() should return True for a valid nickname."""
+        name = 'Unmentionable'
+        self.assertTrue(isValidRouterNickname(name))
+
+    def test_parse_nickname_isValidRouterNickname_valid_1(self):
+        """isValidRouterNickname() should return True for a valid nickname."""
+        name = 'maketotaldestroy'
+        self.assertTrue(isValidRouterNickname(name))
+
+    def test_parse_nickname_isValidRouterNickname_invalid_symbols(self):
+        """isValidRouterNickname() should return False for an invalid nickname
+        (with symbols in it).
+        """
+        name = 'what_the_bl#@p?!'
+        self.assertFalse(isValidRouterNickname(name))
+
+    def test_parse_nickname_isValidRouterNickname_invalid_too_long(self):
+        """isValidRouterNickname() should return False for an invalid nickname
+        (too long).
+        """
+        name = 'ThisIsReallyMoreOfANovellaRatherThanAnOnionRouterNickname'
+        self.assertFalse(isValidRouterNickname(name))
+
+    def test_parse_nickname_isValidRouterNickname_invalid_too_short(self):
+        """isValidRouterNickname() should return False for an invalid nickname
+        (empty string).
+        """
+        name = ''
+        self.assertFalse(isValidRouterNickname(name))
+
+    def test_parse_nickname_isValidRouterNickname_invalid_None(self):
+        """isValidRouterNickname(None) should return False."""
+        name = None
+        self.assertFalse(isValidRouterNickname(name))
+
+    def test_parse_nickname_isValidRouterNickname_invalid_spaces(self):
+        """isValidRouterNickname() should return False for an invalid nickname
+        (contains spaces).
+        """
+        name = 'As you wish'
+        self.assertFalse(isValidRouterNickname(name))



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