dilate/test_manager: tolerate Mock endpoints

This test was incorrectly exercising a member of the endpoint record returned
by `Manager.get_endpoints()`. In the test environment, the `.listen` Endpoint
is actually a Mock, so calling e.g. `listen()` on `endpoints.listen` returns
another Mock instead of a Deferred. Twisted's `assertNoResult` used to
tolerate this silently, but as of Twisted-19.10 it throws an error, causing
the test to fail.

The fix is to assert that the record has attributes with the right names, but
not assume they behave like normal Endpoints, and not call `.listen()` on
them.

closes #366
This commit is contained in:
Brian Warner 2019-12-20 17:03:00 -08:00
parent dd520677fe
commit 6be50a4f0a

View File

@ -237,6 +237,11 @@ class TestManager(unittest.TestCase):
])
clear_mock_calls(h.inbound)
eps = m.get_endpoints()
self.assertTrue(hasattr(eps, "control"))
self.assertTrue(hasattr(eps, "connect"))
self.assertEqual(eps.listen, h.listen_ep)
m.got_wormhole_versions({"can-dilate": ["1"]})
self.assertEqual(h.send.mock_calls, [
mock.call.send("dilate-0",
@ -244,9 +249,6 @@ class TestManager(unittest.TestCase):
])
clear_mock_calls(h.send)
listen_d = m.get_endpoints().listen.listen(None)
self.assertNoResult(listen_d)
# ignore early hints
m.rx_HINTS({})
self.assertEqual(h.send.mock_calls, [])
@ -267,8 +269,6 @@ class TestManager(unittest.TestCase):
self.assertEqual(c.mock_calls, [mock.call.start()])
clear_mock_calls(connector, c)
self.assertNoResult(listen_d)
# now any inbound hints should get passed to our Connector
with mock.patch("wormhole._dilation.manager.parse_hint",
side_effect=["p1", None, "p3"]) as ph: