Пример #1
0
 def test_object_implements(self):
     self.assertTrue(ITorControlProtocol.providedBy(TorControlProtocol()))
Пример #2
0
 def setUp(self):
     self.protocol = TorControlProtocol()
     self.protocol.connectionMade = lambda: None
     self.transport = proto_helpers.StringTransport()
     self.protocol.makeConnection(self.transport)
 def __init__(self, routers):
     self.routers = routers
     self.protocol = TorControlProtocol()
     self.protocol.connectionMade = lambda: None
     self.protocol.transport = proto_helpers.StringTransport()
     self.protocol.makeConnection(self.protocol.transport)
 def setUp(self):
     self.controller = TorState(TorControlProtocol())
     self.controller.connectionMade = lambda _: None
 def setUp(self):
     self.protocol = TorControlProtocol()
     self.transport = proto_helpers.StringTransport()
Пример #6
0
import time

from mock import patch, MagicMock

from ooni.settings import config
from ooni.director import Director
from ooni.tests.bases import ConfigTestCase

from twisted.internet import defer
from twisted.trial import unittest

from txtorcon import TorControlProtocol

proto = MagicMock()
proto.tor_protocol = TorControlProtocol()

mock_TorState = MagicMock()
# We use the instance of mock_TorState so that the mock caching will
# return the same instance when TorState is created.
mts = mock_TorState()
mts.protocol.get_conf = lambda x: defer.succeed({'SocksPort': '4242'})
mts.post_bootstrap = defer.succeed(mts)

# Set the tor_protocol to be already fired
state = MagicMock()
proto.tor_protocol.post_bootstrap = defer.succeed(state)

mock_launch_tor = MagicMock()
mock_launch_tor.return_value = defer.succeed(proto)