Exemple #1
0
    def setUp(self):
        yield super(MultiStoreConduitTest, self).setUp()

        # Stores
        for i in range(self.numberOfStores):
            serversDB = ServersDB()
            for j in range(self.numberOfStores):
                letter = chr(ord("A") + j)
                port = 8008 + 100 * j
                server = Server(letter, "http://127.0.0.1:{}".format(port),
                                letter, j == i)
                serversDB.addServer(server)

            if i == 0:
                yield self.buildStoreAndDirectory(
                    serversDB=serversDB, storeBuilder=self.theStoreBuilders[i])
                self.theStores[i] = self.store
            else:
                self.theStores[i] = yield self.buildStore(
                    self.theStoreBuilders[i])
                directory = buildTestDirectory(self.theStores[i],
                                               self.mktemp(),
                                               serversDB=serversDB)
                self.theStores[i].setDirectoryService(directory)

            self.theStores[i].queryCacher = None  # Cannot use query caching
            self.theStores[i].conduit = self.makeConduit(self.theStores[i])

            FakeConduitRequest.addServerStore(
                serversDB.getServerById(chr(ord("A") + i)), self.theStores[i])
    def test_this_server(self):

        servers = self._setupServers()

        self.assertTrue(servers.getServerById("00001").thisServer)
        self.assertFalse(servers.getServerById("00002").thisServer)

        self.patch(config, "ServerHostName", "caldav2.example.com")
        self.patch(config, "SSLPort", 8443)
        self.patch(config, "BindSSLPorts", [8843])

        xmlFile = StringIO.StringIO(ServerTests.data1)
        servers = ServersDB()
        servers.load(xmlFile, ignoreIPLookupFailures=True)

        self.assertFalse(servers.getServerById("00001").thisServer)
        self.assertTrue(servers.getServerById("00002").thisServer)
    def test_this_server(self):

        servers = self._setupServers()

        self.assertTrue(servers.getServerById("00001").thisServer)
        self.assertFalse(servers.getServerById("00002").thisServer)

        self.patch(config, "ServerHostName", "caldav2.example.com")
        self.patch(config, "SSLPort", 8443)
        self.patch(config, "BindSSLPorts", [8843])

        xmlFile = StringIO.StringIO(ServerTests.data1)
        servers = ServersDB()
        servers.load(xmlFile, ignoreIPLookupFailures=True)

        self.assertFalse(servers.getServerById("00001").thisServer)
        self.assertTrue(servers.getServerById("00002").thisServer)
Exemple #4
0
    def setUp(self):
        yield super(MultiStoreConduitTest, self).setUp()

        # Stores
        for i in range(self.numberOfStores):
            serversDB = ServersDB()
            for j in range(self.numberOfStores):
                letter = chr(ord("A") + j)
                port = 8008 + 100 * j
                server = Server(
                    letter, "http://127.0.0.1:{}".format(port), letter, j == i
                )
                serversDB.addServer(server)

            if i == 0:
                yield self.buildStoreAndDirectory(
                    serversDB=serversDB,
                    storeBuilder=self.theStoreBuilders[i],
                    accounts=self.accounts,
                    augments=self.augments,
                )
                self.theStores[i] = self.store
            else:
                self.theStores[i] = yield self.buildStore(
                    self.theStoreBuilders[i]
                )
                directory = buildTestDirectory(
                    self.theStores[i],
                    self.mktemp(),
                    serversDB=serversDB,
                    accounts=self.accounts,
                    augments=self.augments,
                )
                self.theStores[i].setDirectoryService(directory)

            self.theStores[i].queryCacher = None     # Cannot use query caching
            self.theStores[i].conduit = self.makeConduit(self.theStores[i])

            FakeConduitRequest.addServerStore(
                serversDB.getServerById(chr(ord("A") + i)), self.theStores[i]
            )