Skip to content

Commit

Permalink
become_ready tests
Browse files Browse the repository at this point in the history
  • Loading branch information
meejah committed Sep 21, 2017
1 parent 9025173 commit 0601710
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/test_controller.py
Expand Up @@ -1097,6 +1097,7 @@ def setUp(self):
self.proto = Mock()
self.cfg = Mock()
self.tor = Tor(reactor, self.proto, _tor_config=self.cfg)
self.tor.dns_resolve = Mock()

@defer.inlineCallbacks
def test_ready(self):
Expand All @@ -1108,6 +1109,27 @@ def test_ready(self):
ready = yield self.tor.is_ready()
self.assertTrue(ready, "should be ready")

@defer.inlineCallbacks
def test_become_ready_already(self):
self.proto.get_info = Mock(return_value={
"dormant": "0",
"status/enough-dir-info": "1",
"status/circuit-established": "1",
})
ready = yield self.tor.become_ready()
self.assertTrue(
self.tor.dns_resolve.mock_calls == []
)

@defer.inlineCallbacks
def test_become_ready_asleep(self):
self.proto.get_info = Mock(return_value={
"dormant": "1",
"status/enough-dir-info": "1",
"status/circuit-established": "1",
})
ready = yield self.tor.become_ready()
self.assertEqual(1, len(self.tor.dns_resolve.mock_calls))


class TorStreamTests(unittest.TestCase):
Expand Down

0 comments on commit 0601710

Please sign in to comment.