class AbstractReviewQueue(AbstractPatchQueue, PersistentPatchCollectionDelegate, StepSequenceErrorHandler): def __init__(self, options=None): AbstractPatchQueue.__init__(self, options) def review_patch(self, patch): raise NotImplementedError, "subclasses must implement" # PersistentPatchCollectionDelegate methods def collection_name(self): return self.name def fetch_potential_patch_ids(self): return self.tool.bugs.queries.fetch_attachment_ids_from_review_queue() def status_server(self): return self.tool.status_server def is_terminal_status(self, status): return status == "Pass" or status == "Fail" or status.startswith( "Error:") # AbstractPatchQueue methods def begin_work_queue(self): AbstractPatchQueue.begin_work_queue(self) self._patches = PersistentPatchCollection(self) def next_work_item(self): patch_id = self._patches.next() if patch_id: return self.tool.bugs.fetch_attachment(patch_id) self._update_status("Empty queue") def should_proceed_with_work_item(self, patch): raise NotImplementedError, "subclasses must implement" def process_work_item(self, patch): try: if not self.review_patch(patch): return False self._did_pass(patch) return True except ScriptError, e: if e.exit_code != QueueEngine.handled_error_code: self._did_fail(patch) raise e
class AbstractReviewQueue(AbstractPatchQueue, PersistentPatchCollectionDelegate, StepSequenceErrorHandler): def __init__(self, options=None): AbstractPatchQueue.__init__(self, options) def review_patch(self, patch): raise NotImplementedError, "subclasses must implement" # PersistentPatchCollectionDelegate methods def collection_name(self): return self.name def fetch_potential_patch_ids(self): return self.tool.bugs.queries.fetch_attachment_ids_from_review_queue() def status_server(self): return self.tool.status_server def is_terminal_status(self, status): return status == "Pass" or status == "Fail" or status.startswith("Error:") # AbstractPatchQueue methods def begin_work_queue(self): AbstractPatchQueue.begin_work_queue(self) self._patches = PersistentPatchCollection(self) def next_work_item(self): patch_id = self._patches.next() if patch_id: return self.tool.bugs.fetch_attachment(patch_id) self._update_status("Empty queue") def should_proceed_with_work_item(self, patch): raise NotImplementedError, "subclasses must implement" def process_work_item(self, patch): try: if not self.review_patch(patch): return False self._did_pass(patch) return True except ScriptError, e: if e.exit_code != QueueEngine.handled_error_code: self._did_fail(patch) raise e
def test_next(self): collection = PersistentPatchCollection( TestPersistentPatchCollectionDelegate()) collection.next()
def test_next(self): collection = PersistentPatchCollection(TestPersistentPatchCollectionDelegate()) collection.next()