[tor-commits] [bridgedb/master] Add unittests for bridgedb.parse.networkstatus.parseSLine().

isis at torproject.org isis at torproject.org
Sun Jan 12 06:06:34 UTC 2014


commit a1536800674ac587d22d0a6e4de9af053e5958cd
Author: Isis Lovecruft <isis at torproject.org>
Date:   Sat Dec 7 12:55:34 2013 +0000

    Add unittests for bridgedb.parse.networkstatus.parseSLine().
---
 lib/bridgedb/test/test_parse_networkstatus.py |   28 +++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/lib/bridgedb/test/test_parse_networkstatus.py b/lib/bridgedb/test/test_parse_networkstatus.py
index 31fb1e2..bbae59c 100644
--- a/lib/bridgedb/test/test_parse_networkstatus.py
+++ b/lib/bridgedb/test/test_parse_networkstatus.py
@@ -320,3 +320,31 @@ class ParseNetworkStatusALineTests(unittest.TestCase):
         this(ip).should.be.a(basestring)
         this(port).should.be.ok
         this(port).should.be.a(networkstatus.addr.PortList)
+
+
+class ParseNetworkStatusSLineTests(unittest.TestCase):
+    """Tests for :func:`bridgedb.parse.networkstatus.parseSLine`."""
+
+    def tearDown(self):
+        """Automatically called after each test_* method to run cleanups."""
+        self.line = ''
+
+    def test_missingPrefix(self):
+        self.line = 'Stable'
+        running, stable = networkstatus.parseSLine(self.line)
+        self.assertFalse(running)
+        self.assertFalse(stable)
+
+    def test_makeBelieveFlag(self):
+        """Test that 's'-parser should ignore a 'MakeBelieve' flag."""
+        self.line = 's Stable Running MakeBelieve BadExit'
+        running, stable = networkstatus.parseSLine(self.line)
+        self.assertTrue(running)
+        self.assertTrue(stable)
+
+    def test_noFlags(self):
+        """Test that an 's'-line with no flags returns False for everything."""
+        self.line = ''
+        running, stable = networkstatus.parseSLine(self.line)
+        self.assertFalse(running)
+        self.assertFalse(stable)





More information about the tor-commits mailing list