~facundo/magicicada-server/incorporate-venv-client

« back to all changes in this revision

Viewing changes to magicicada/server/integtests/test_action_queue.py

  • Committer: Facundo Batista
  • Date: 2018-03-20 19:21:27 UTC
  • mto: This revision was merged to the branch mainline in revision 84.
  • Revision ID: facundo@taniquetil.com.ar-20180320192127-12gnfgeu7lkzhgg7
Updated magicicada client to r1440.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
    ActionQueue,
36
36
    Download,
37
37
    Upload,
38
 
    dns_client,
39
38
)
40
39
from ubuntuone.syncdaemon.marker import MDMarker as Marker
41
40
 
42
41
from magicicada.server.testing.aq_helpers import (
43
42
    FakeFailure,
44
 
    FakeResolver,
45
43
    NO_CONTENT_HASH,
46
44
    NoCloseStringIO,
47
45
    TestBase,
958
956
        d.addBoth(lambda _: self.main.wait_for_nirvana())
959
957
        d.addBoth(lambda _: self.eq.push('SYS_USER_DISCONNECT'))
960
958
        return d
961
 
 
962
 
 
963
 
class SRVLookupTest(TestWithDatabase):
964
 
    """ Test for SRV lookup in the ActionQueue. """
965
 
 
966
 
    @defer.inlineCallbacks
967
 
    def setUp(self):
968
 
        """
969
 
        Replace the resolver with a FakeResolver
970
 
        """
971
 
        yield super(SRVLookupTest, self).setUp()
972
 
        dns_client.theResolver = FakeResolver()
973
 
 
974
 
    @defer.inlineCallbacks
975
 
    def tearDown(self):
976
 
        """
977
 
        By setting the resolver to None, it will be recreated next time a name
978
 
        lookup is done.
979
 
        """
980
 
        yield super(SRVLookupTest, self).tearDown()
981
 
        dns_client.theResolver = None
982
 
 
983
 
    def test_SRV_lookup_dev(self):
984
 
        """Test the srv lookup in development mode (localhost:<randomport>)."""
985
 
 
986
 
        def checkResult(result):
987
 
            """ Verify that we are correclty doing the lookup """
988
 
            host, port = result
989
 
            self.assertEqual(host, self.aq.host)
990
 
 
991
 
        d = self.aq._lookup_srv()
992
 
        d.addCallback(checkResult)
993
 
        return d
994
 
 
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 """
999
 
            host, port = result
1000
 
            self.assertTrue(host in ['fs-1.server.com', 'fs-0.server.com'],
1001
 
                            host)
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)