def test_event_details_updated(self): affected_refs = { 'key': {ndb.Key(EventDetails, '2015casj'), ndb.Key(EventDetails, '2015cama')}, } cache_keys = [q.cache_key for q in get_affected_queries.event_details_updated(affected_refs)] self.assertEqual(len(cache_keys), 2) self.assertTrue(EventDetailsQuery('2015casj').cache_key in cache_keys) self.assertTrue(EventDetailsQuery('2015cama').cache_key in cache_keys)
def _render(self, event_key, detail_type): event_details, self._last_modified = EventDetailsQuery( event_key).fetch(dict_version=3, return_updated=True) return json.dumps(event_details[detail_type], ensure_ascii=True, indent=2, sort_keys=True)
def event_details_updated(affected_refs): event_details_keys = filter(None, affected_refs['key']) queries_and_keys = [] for event_details_key in event_details_keys: queries_and_keys.append((EventDetailsQuery(event_details_key.id()))) return queries_and_keys
def _render(self, event_key, detail_type): event_details, self._last_modified = EventDetailsQuery(event_key).fetch(dict_version=3, return_updated=True) if detail_type == 'alliances' and event_details[detail_type]: data = self._add_alliance_status(event_key, event_details[detail_type]) else: data = event_details[detail_type] return json.dumps(data, ensure_ascii=True, indent=2, sort_keys=True)