[tor-commits] [bridgedb/master] Add unittests for the new bridgedb.bridges.Flags class.

isis at torproject.org isis at torproject.org
Sat Mar 21 02:02:58 UTC 2015


commit 5050990c02796b1d3a9194c3d4b1e4d76b5aa3f5
Author: Isis Lovecruft <isis at torproject.org>
Date:   Fri Dec 5 23:15:06 2014 +0000

    Add unittests for the new bridgedb.bridges.Flags class.
---
 lib/bridgedb/test/test_bridges.py |   43 +++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/lib/bridgedb/test/test_bridges.py b/lib/bridgedb/test/test_bridges.py
index 6164620..6ca96de 100644
--- a/lib/bridgedb/test/test_bridges.py
+++ b/lib/bridgedb/test/test_bridges.py
@@ -281,3 +281,46 @@ class BridgeIntegrationTests(unittest.TestCase):
         splitter.insert(bridge4)
         # Check that identical bridges are not inserted twice
         self.failUnlessEqual(len(splitter), 3)
+
+
+class FlagsTests(unittest.TestCase):
+    """Tests for :class:`bridgedb.bridges.Flags`."""
+
+    def setUp(self):
+        self.flags = bridges.Flags()
+        self._all_flag_names = ["fast", "guard", "running", "stable", "valid"]
+
+    def test_init(self):
+        """Upon initialisation, all flags should be ``False``."""
+        for flag in self._all_flag_names:
+            f = getattr(self.flags, flag, None)
+            self.assertFalse(f, "%s should be False" % flag)
+
+    def test_settingStable(self):
+        """Setting the Stable flag to ``True`` should result in Flags.stable
+        being ``True``.
+        """
+        self.flags.stable = True
+        self.assertTrue(self.flags.stable, "The Stable flag should be True")
+
+    def test_settingRunning(self):
+        """Setting the Running flag to ``True`` should result in Flags.running
+        being ``True``.
+        """
+        self.flags.running = True
+        self.assertTrue(self.flags.running, "The Running flag should be True")
+
+    def test_changingFlags(self):
+        """Setting a flag and then unsetting it should result in it being
+        ``True`` and then ``False``.
+        """
+        self.flags.valid = True
+        self.assertTrue(self.flags.valid, "The Valid flag should be True")
+        self.flags.valid = False
+        self.assertFalse(self.flags.valid, "The Valid flag should be False")
+
+    def test_update(self):
+        """Test changing flags with the update() method."""
+        self.flags.update(["Fast", "Stable"])
+        self.assertTrue(self.flags.fast)
+        self.assertTrue(self.flags.stable)





More information about the tor-commits mailing list