Moved into allmydata.test.test_i2p_provider

This follows the local convention of using mock even though I'm trying to get
rid of mock.  This is because it keeps the test_i2p_provider suite consistent
which means it won't make removing mock from test_i2p_provider later much
harder and lets me avoid doing that work now.
This commit is contained in:
Jean-Paul Calderone 2020-12-16 11:20:45 -05:00
parent 8271dbf3e6
commit 7eb9f2ce54
2 changed files with 14 additions and 16 deletions

View File

@ -174,22 +174,6 @@ class I2P(unittest.TestCase):
str(ctx.exception)
)
def test_launch_executable(self):
config = config_from_string(
"fake.port",
"no-basedir",
BASECONFIG + "[i2p]\nlaunch = true\n" + "i2p.executable = i2p\n",
)
h1 = mock.Mock()
with mock.patch("foolscap.connections.i2p.launch",
return_value=h1) as f:
i2p_provider = create_i2p_provider(reactor, config)
h = i2p_provider.get_i2p_handler()
exp = mock.call(i2p_configdir=None, i2p_binary="i2p")
self.assertEqual(f.mock_calls, [exp])
self.assertIdentical(h, h1)
class Connections(unittest.TestCase):
def setUp(self):

View File

@ -277,6 +277,20 @@ class Provider(unittest.TestCase):
i2p.local_i2p.assert_called_with("configdir")
self.assertIs(h, handler)
def test_handler_launch_executable(self):
i2p = mock.Mock()
handler = object()
i2p.launch = mock.Mock(return_value=handler)
reactor = object()
with mock_i2p(i2p):
p = i2p_provider.create(reactor,
FakeConfig(launch=True,
**{"i2p.executable": "myi2p"}))
h = p.get_i2p_handler()
self.assertIs(h, handler)
i2p.launch.assert_called_with(i2p_configdir=None, i2p_binary="myi2p")
def test_handler_default(self):
i2p = mock.Mock()
handler = object()