958
956
d.addBoth(lambda _: self.main.wait_for_nirvana())
959
957
d.addBoth(lambda _: self.eq.push('SYS_USER_DISCONNECT'))
963
class SRVLookupTest(TestWithDatabase):
964
""" Test for SRV lookup in the ActionQueue. """
966
@defer.inlineCallbacks
969
Replace the resolver with a FakeResolver
971
yield super(SRVLookupTest, self).setUp()
972
dns_client.theResolver = FakeResolver()
974
@defer.inlineCallbacks
977
By setting the resolver to None, it will be recreated next time a name
980
yield super(SRVLookupTest, self).tearDown()
981
dns_client.theResolver = None
983
def test_SRV_lookup_dev(self):
984
"""Test the srv lookup in development mode (localhost:<randomport>)."""
986
def checkResult(result):
987
""" Verify that we are correclty doing the lookup """
989
self.assertEqual(host, self.aq.host)
991
d = self.aq._lookup_srv()
992
d.addCallback(checkResult)
995
def test_SRV_lookup_prod(self):
996
""" test the srv lookup using a fake resolver. """
997
def checkResult(result):
998
""" Verify that we are correclty doing the lookup """
1000
self.assertTrue(host in ['fs-1.server.com', 'fs-0.server.com'],
1002
self.assertEqual(port, 443)
1003
self.aq.dns_srv = '_http._tcp.fs.server.com'
1004
d = self.aq._lookup_srv()
1005
d.addCallback(checkResult)