def xxxNOT_WORKING_YETxxxtestUpdateDirtyWithResultTimeKey(self): ua_string = ('Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.6) ' 'Gecko/2009011912 Firefox/3.0.6') result_parent = ResultParent.AddResult(self.test_set, '12.2.2.11', ua_string, 'apple=0,banana=99,coconut=101', skip_update_dirty=True) skip_rt, update_rt, next_rt = result_parent.GetResultTimes() # Make so there is only one ResultTime to schedule after first update. skip_rt.dirty = False skip_rt.put() self.mox.StubOutWithMock(ResultTime, 'UpdateStats') self.mox.StubOutWithMock(ResultParent, 'ScheduleUpdateDirty') ResultTime.UpdateStats(update_rt) ResultParent.ScheduleUpdateDirty(next_rt.key()) self.mox.ReplayAll() response = self.client.get('/admin/update_dirty/some_category', {'result_time_key': update_rt.key()}, **mock_data.UNIT_TEST_UA) self.mox.VerifyAll()
def UpdateDirty(request): """Updates any dirty tests, adding its score to the appropriate ranker.""" logging.debug('UpdateDirty start.') task_name_prefix = request.REQUEST.get('task_name_prefix', '') result_time_key = request.REQUEST.get('result_time_key') category = request.REQUEST.get('category') count = int(request.REQUEST.get('count', 0)) if result_time_key: result_time = ResultTime.get(result_time_key) try: ResultTime.UpdateStats(result_time) except: logging.info('UpdateStats: %s:%s' % (sys.exc_type, sys.exc_value)) result_parent_key = result_time.parent_key() else: result_parent_key = request.REQUEST.get('result_parent_key') if result_parent_key: result_parent_key = db.Key(result_parent_key) else: UpdateOldDirty() return http.HttpResponse('Done scheduling old results.') # Create a task for the next dirty ResultTime to update. dirty_query = ResultTime.all(keys_only=True) dirty_query.filter('dirty =', True) dirty_query.ancestor(result_parent_key) next_result_time_key = dirty_query.get() if next_result_time_key: logging.debug('Schedule next ResultTime: %s', next_result_time_key) ResultParent.ScheduleUpdateDirty(next_result_time_key, category, count + 1, task_name_prefix) else: logging.debug('Done with result_parent: %s', result_parent_key) ScheduleCategoryUpdate(result_parent_key) shardedcounter.increment(category) return http.HttpResponse('Done.')