address review feedback: docstrings, better test class name

This commit is contained in:
Brian Warner 2017-08-15 17:59:59 -07:00
parent 097abb42fa
commit d713e0e57d
3 changed files with 16 additions and 2 deletions

View File

@ -401,6 +401,11 @@ class Node(service.MultiService):
if port in ("0", "tcp:0"):
raise ValueError("tub.port cannot be 0: you must choose")
if port == "listen:i2p":
# the I2P provider will read its section of tahoe.cfg and
# return either a fully-formed Endpoint, or a descriptor
# that will create one, so we don't have to stuff all the
# options into the tub.port string (which would need a lot
# of escaping)
port_or_endpoint = self._i2p_provider.get_listener()
elif port == "listen:tor":
port_or_endpoint = self._tor_provider.get_listener()

View File

@ -294,8 +294,13 @@ class Provider(unittest.TestCase):
self.assertIs(h, handler)
i2p.default.assert_called_with(reactor, keyfile=None)
class Provider_Listener(unittest.TestCase):
class ProviderListener(unittest.TestCase):
def test_listener(self):
"""Does the I2P Provider object's get_listener() method correctly
convert the [i2p] section of tahoe.cfg into an
endpoint/descriptor?
"""
i2p = mock.Mock()
handler = object()
i2p.local_i2p = mock.Mock(return_value=handler)

View File

@ -393,8 +393,12 @@ class Provider(unittest.TestCase):
self.assertIs(h, handler)
tor.default_socks.assert_called_with()
class Provider_Listener(unittest.TestCase):
class ProviderListener(unittest.TestCase):
def test_listener(self):
"""Does the Tor Provider object's get_listener() method correctly
convert the [tor] section of tahoe.cfg into an
endpoint/descriptor?
"""
tor = mock.Mock()
handler = object()
tor.socks_endpoint = mock.Mock(return_value=handler)