示例#1
0
 def testHarvesterIgnoringInvalidDataErrors(self):
     observer = CallTrace('observer')
     upload = Upload(repository=None, oaiResponse=oaiResponse(identifier='mockid'))
     upload.id = 'mockid'
     observer.returnValues['createUpload'] = upload
     observer.returnValues['totalInvalidIds'] = 0
     observer.exceptions['send'] =  InvalidDataException(upload.id, "message")
     repository=CallTrace("repository", returnValues={'maxIgnore': 100})
     harvester = Harvester(repository)
     harvester.addObserver(observer)
     harvester.upload(oaiResponse())
     self.assertEquals(['createUpload', "notifyHarvestedRecord", "send", 'logInvalidData', "totalInvalidIds", 'logIgnoredIdentifierWarning'], [m.name for m in observer.calledMethods])
示例#2
0
 def testHarvesterIgnoringInvalidDataErrors(self):
     observer = CallTrace('observer')
     upload = Upload(repository=None,
                     oaiResponse=oaiResponse(identifier='mockid'))
     upload.id = 'mockid'
     observer.returnValues['createUpload'] = upload
     observer.returnValues['totalInvalidIds'] = 0
     observer.exceptions['send'] = InvalidDataException(
         upload.id, "message")
     repository = CallTrace("repository", returnValues={'maxIgnore': 100})
     harvester = Harvester(repository)
     harvester.addObserver(observer)
     harvester.upload(oaiResponse())
     self.assertEqual([
         'createUpload', "notifyHarvestedRecord", "send", 'logInvalidData',
         "totalInvalidIds", 'logIgnoredIdentifierWarning'
     ], [m.name for m in observer.calledMethods])
示例#3
0
 def testHarvesterStopsIgnoringAfter100records(self):
     observer = CallTrace('observer')
     upload = Upload(repository=None, oaiResponse=oaiResponse(identifier='mockid'))
     upload.id = 'mockid'
     observer.returnValues['createUpload'] = upload
     observer.returnValues['totalInvalidIds'] = 101
     observer.exceptions['send'] =  InvalidDataException(upload.id, "message")
     repository=CallTrace("repository", returnValues={'maxIgnore': 100})
     harvester = Harvester(repository)
     harvester.addObserver(observer)
     self.assertRaises(TooMuchInvalidDataException, lambda: harvester.upload(oaiResponse(identifier='mockid')))
     self.assertEquals(['createUpload', "notifyHarvestedRecord", "send", "logInvalidData", "totalInvalidIds"], [m.name for m in observer.calledMethods])
示例#4
0
 def testHarvesterStopsIgnoringAfter100records(self):
     observer = CallTrace('observer')
     upload = Upload(repository=None,
                     oaiResponse=oaiResponse(identifier='mockid'))
     upload.id = 'mockid'
     observer.returnValues['createUpload'] = upload
     observer.returnValues['totalInvalidIds'] = 101
     observer.exceptions['send'] = InvalidDataException(
         upload.id, "message")
     repository = CallTrace("repository", returnValues={'maxIgnore': 100})
     harvester = Harvester(repository)
     harvester.addObserver(observer)
     self.assertRaises(
         TooMuchInvalidDataException,
         lambda: harvester.upload(oaiResponse(identifier='mockid')))
     self.assertEqual([
         'createUpload', "notifyHarvestedRecord", "send", "logInvalidData",
         "totalInvalidIds"
     ], [m.name for m in observer.calledMethods])