Exemplo n.º 1
0
    def test_query_cache(self):
        _clear_stats()
        cq_stats = _add_stats('project_a', 1, 0)
        response = self.test_app.get('/stats/query')
        self.assertEquals(
            {
                'more':
                False,
                'results': [{
                    'project': 'project_a',
                    'interval_minutes': 1 * minutes_per_day,
                    'begin': 0,
                    'end': 86400,
                    'stats': [],
                }],
            }, _parse_body(response))

        cq_stats.project = 'project_b'
        cq_stats.put()
        response = self.test_app.get('/stats/query')
        self.assertEquals(
            {
                'more':
                False,
                'results': [{
                    'project': 'project_a',
                    'interval_minutes': 1 * minutes_per_day,
                    'begin': 0,
                    'end': 86400,
                    'stats': [],
                }],
            }, _parse_body(response))

        memcache.set(LAST_CQ_STATS_CHANGE_KEY, timestamp_now())
        response = self.test_app.get('/stats/query')
        self.assertEquals(
            {
                'more':
                False,
                'results': [{
                    'project': 'project_b',
                    'interval_minutes': 1 * minutes_per_day,
                    'begin': 0,
                    'end': 86400,
                    'stats': [],
                }],
            }, _parse_body(response))
Exemplo n.º 2
0
def update_last_cq_stats_change_timestamp(minutes):  # pragma: no cover
    now = timestamp_now()
    memcache.set(LAST_CQ_STATS_INTERVAL_CHANGE_KEY % minutes, now)
    memcache.set(LAST_CQ_STATS_CHANGE_KEY, now)
Exemplo n.º 3
0
def ensure_last_change_timestamp(interval_minutes): # pragma: no cover
  """Ensure a memcache timestamp is set for the last CQStats change."""
  last_change_key = get_last_change_key(interval_minutes)
  last_change_timestamp = memcache.get(last_change_key)
  if last_change_timestamp is None:
    memcache.set(last_change_key, utils.timestamp_now())
Exemplo n.º 4
0
def ensure_last_change_timestamp(interval_minutes):
    """Ensure a memcache timestamp is set for the last CQStats change."""
    last_change_key = get_last_change_key(interval_minutes)
    last_change_timestamp = memcache.get(last_change_key)
    if last_change_timestamp is None:
        memcache.set(last_change_key, utils.timestamp_now())
Exemplo n.º 5
0
def update_last_cq_stats_change_timestamp(minutes): # pragma: no cover
  now = timestamp_now()
  memcache.set(LAST_CQ_STATS_INTERVAL_CHANGE_KEY % minutes, now)
  memcache.set(LAST_CQ_STATS_CHANGE_KEY, now)