commit 00a9288a141158552ee56790211ed230704775d7 Author: Isis Lovecruft isis@torproject.org Date: Thu Nov 2 00:27:31 2017 +0000
Add more tests for bridgedb.main. --- bridgedb/main.py | 4 ++-- bridgedb/test/test_main.py | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/bridgedb/main.py b/bridgedb/main.py index cb3eee1..d155a28 100644 --- a/bridgedb/main.py +++ b/bridgedb/main.py @@ -459,7 +459,7 @@ def run(options, reactor=reactor): signal.signal(signal.SIGHUP, _handleSIGHUP) signal.signal(signal.SIGUSR1, _handleSIGUSR1)
- if reactor: + if reactor: # pragma: no cover # And actually load it to start parsing. Get back our distributors. emailDistributor, ipDistributor = reload(False)
@@ -508,7 +508,7 @@ def run(options, reactor=reactor): if reactor and not reactor.running: logging.info("Starting reactors.") reactor.run() - except KeyboardInterrupt: + except KeyboardInterrupt: # pragma: no cover logging.fatal("Received keyboard interrupt. Shutting down...") finally: if config.PIDFILE: diff --git a/bridgedb/test/test_main.py b/bridgedb/test/test_main.py index a2e975e..ab34055 100644 --- a/bridgedb/test/test_main.py +++ b/bridgedb/test/test_main.py @@ -71,6 +71,20 @@ class MockHashring(object): pass
+class ExpandBridgeAuthDirTests(unittest.TestCase): + """Unittests for :func:`bridgedb.main.expandBridgeAuthDir`.""" + + def setUp(self): + self.authdir = "from-authority" + self.filename = "bridge-descriptors" + + def test_expandBridgeAuthDir_not_abs(self): + """A non-absolute path should turn into an absolute one.""" + result = main.expandBridgeAuthDir(self.authdir, self.filename) + + self.assertTrue(os.path.isabs(result)) + + class BridgedbTests(unittest.TestCase): """Integration tests for :func:`bridgedb.main.load`."""
@@ -229,6 +243,15 @@ class BridgedbTests(unittest.TestCase): d.addErrback(self._eb_Failure) return d
+ def test_main_load_then_reload(self): + """main.load() should run without error.""" + d = deferToThread(main.load, self.state, self.hashring) + d.addCallback(self._cbAssertFingerprints) + d.addErrback(self._eb_Failure) + d.addCallback(main._reloadFn) + d.addErrback(self._eb_Failure) + return d + def test_main_load_no_state(self): """main.load() should raise SystemExit without a state object.""" self.assertRaises(SystemExit, main.load, None, self.hashring)
tor-commits@lists.torproject.org