def testEachBatchWillHaveItsOwnTimestamp(self): reactor = CallTrace("reactor") register = SuspendRegister(batchMode=True) register.signalOaiUpdate(metadataPrefixes=['prefix'], sets=set(), otherKey='ignored', stamp=1000) register.startOaiBatch() suspend = next( compose( register.suspendBeforeSelect(clientIdentifier="id0", prefix='prefix', sets=[], continueAfter='1000'))) suspend(reactor, lambda: None) register.signalOaiUpdate(metadataPrefixes=['prefix'], sets=set(), otherKey='ignored', stamp=2000) self.assertEqual(1, len(register)) register.stopOaiBatch() self.assertEqual(0, len(register)) register.startOaiBatch() self.assertEqual([], asList( register.suspendBeforeSelect( clientIdentifier="id0", prefix='prefix', sets=[], continueAfter='1000'))) self.assertEqual(0, len(register))
def testEachBatchWillHaveItsOwnTimestamp(self): reactor = CallTrace("reactor") register = SuspendRegister(batchMode=True) register.signalOaiUpdate(metadataPrefixes=['prefix'], sets=set(), otherKey='ignored', stamp=1000) register.startOaiBatch() suspend = compose(register.suspendBeforeSelect(clientIdentifier="id0", prefix='prefix', sets=[], continueAfter='1000')).next() suspend(reactor, lambda: None) register.signalOaiUpdate(metadataPrefixes=['prefix'], sets=set(), otherKey='ignored', stamp=2000) self.assertEquals(1, len(register)) register.stopOaiBatch() self.assertEquals(0, len(register)) register.startOaiBatch() self.assertEquals([], asList(register.suspendBeforeSelect(clientIdentifier="id0", prefix='prefix', sets=[], continueAfter='1000'))) self.assertEquals(0, len(register))
def testInitialBatchSuspendBeforeResult(self): register = SuspendRegister(batchMode=True) register.startOaiBatch() self.assertEqual([], asList( register.suspendBeforeSelect( clientIdentifier="a-client-id", prefix='prefix', sets=[], continueAfter='0'))) self.assertEqual([], asList( register.suspendBeforeSelect( clientIdentifier="a-client-id", prefix='prefix', sets=[], continueAfter='1000')))
def testSuspendBeforeSelectWithContinueAfter(self): reactor = CallTrace("reactor") register = SuspendRegister(batchMode=True) register.signalOaiUpdate(metadataPrefixes=['prefix'], sets=set(), otherKey='ignored', stamp=1000) register.startOaiBatch() resumed = [] suspend = next( compose( register.suspendBeforeSelect(clientIdentifier="id0", prefix='prefix', sets=[], continueAfter='1000'))) suspend(reactor, lambda: resumed.append(True)) suspend = next( compose( register.suspendBeforeSelect(clientIdentifier="id1", prefix='prefix', sets=[], continueAfter='1001'))) suspend(reactor, lambda: resumed.append(True)) self.assertEqual([], asList( register.suspendBeforeSelect( clientIdentifier="id2", prefix='prefix', sets=[], continueAfter='999'))) self.assertEqual([], resumed) register.signalOaiUpdate(metadataPrefixes=['prefix'], sets=set(), otherKey='ignored', stamp=2000) self.assertEqual([], resumed) self.assertEqual(2, len(register)) register.stopOaiBatch() self.assertEqual([True, True], resumed) self.assertEqual(0, len(register))
def testSuspendBeforeSelectWithContinueAfter(self): reactor = CallTrace("reactor") register = SuspendRegister(batchMode=True) register.signalOaiUpdate(metadataPrefixes=['prefix'], sets=set(), otherKey='ignored', stamp=1000) register.startOaiBatch() resumed = [] suspend = compose(register.suspendBeforeSelect(clientIdentifier="id0", prefix='prefix', sets=[], continueAfter='1000')).next() suspend(reactor, lambda: resumed.append(True)) suspend = compose(register.suspendBeforeSelect(clientIdentifier="id1", prefix='prefix', sets=[], continueAfter='1001')).next() suspend(reactor, lambda: resumed.append(True)) self.assertEquals([], asList(register.suspendBeforeSelect(clientIdentifier="id2", prefix='prefix', sets=[], continueAfter='999'))) self.assertEquals([], resumed) register.signalOaiUpdate(metadataPrefixes=['prefix'], sets=set(), otherKey='ignored', stamp=2000) self.assertEquals([], resumed) self.assertEquals(2, len(register)) register.stopOaiBatch() self.assertEquals([True, True], resumed) self.assertEquals(0, len(register))
def testInitialBatchSuspendBeforeResult(self): register = SuspendRegister(batchMode=True) register.startOaiBatch() self.assertEquals([], asList(register.suspendBeforeSelect(clientIdentifier="a-client-id", prefix='prefix', sets=[], continueAfter='0'))) self.assertEquals([], asList(register.suspendBeforeSelect(clientIdentifier="a-client-id", prefix='prefix', sets=[], continueAfter='1000')))