def setUp(self): yield super(DPSClientAugmentedAggregateDirectoryTest, self).setUp() # The "local" directory service self.client = DirectoryService(None) # The "remote" directory service remoteDirectory = self.directory # Connect the two services directly via an IOPump client = AMP() server = DirectoryProxyAMPProtocol(remoteDirectory) pump = returnConnected(server, client) # Replace the normal _getConnection method with one that bypasses any # actual networking self.patch(self.client, "_getConnection", lambda: succeed(client)) # Wrap the normal _sendCommand method with one that flushes the IOPump # afterwards origCall = self.client._sendCommand def newCall(*args, **kwds): d = origCall(*args, **kwds) pump.flush() return d self.patch(self.client, "_sendCommand", newCall)
def setUp(self): self.numUsers = 1000 # The "local" directory service self.directory = DirectoryService(None) # The "remote" directory service remoteDirectory = CalendarInMemoryDirectoryService(None) # Add users records = [] fieldName = remoteDirectory.fieldName for i in xrange(self.numUsers): records.append( TestRecord( remoteDirectory, { fieldName.uid: u"foo{ctr:05d}".format(ctr=i), fieldName.shortNames: (u"foo{ctr:05d}".format(ctr=i), ), fieldName.fullNames: (u"foo{ctr:05d}".format(ctr=i), ), fieldName.recordType: RecordType.user, })) # Add a big group records.append( TestRecord( remoteDirectory, { fieldName.uid: u"bigGroup", fieldName.recordType: RecordType.group, })) yield remoteDirectory.updateRecords(records, create=True) group = yield remoteDirectory.recordWithUID(u"bigGroup") members = yield remoteDirectory.recordsWithRecordType(RecordType.user) yield group.setMembers(members) # Connect the two services directly via an IOPump client = AMP() self.server = DirectoryProxyAMPProtocol(remoteDirectory) pump = returnConnected(self.server, client) # Replace the normal _getConnection method with one that bypasses any # actual networking self.patch(self.directory, "_getConnection", lambda: succeed(client)) # Wrap the normal _call method with one that flushes the IOPump # afterwards origCall = self.directory._call def newCall(*args, **kwds): d = origCall(*args, **kwds) pump.flush() return d self.patch(self.directory, "_call", newCall)