def test_match_updated(self):
        affected_refs = {
            'key': {ndb.Key(Match, '2015casj_qm1'), ndb.Key(Match, '2015casj_qm2')},
            'event': {ndb.Key(Event, '2015casj'), ndb.Key(Event, '2015cama')},
            'team_keys': {ndb.Key(Team, 'frc254'), ndb.Key(Team, 'frc604')},
            'year': {2014, 2015},
        }
        cache_keys = [q.cache_key for q in get_affected_queries.match_updated(affected_refs)]

        self.assertEqual(len(cache_keys), 16)
        self.assertTrue(MatchQuery('2015casj_qm1').cache_key in cache_keys)
        self.assertTrue(MatchQuery('2015casj_qm2').cache_key in cache_keys)
        self.assertTrue(MatchGdcvDataQuery('2015casj_qm1').cache_key in cache_keys)
        self.assertTrue(MatchGdcvDataQuery('2015casj_qm2').cache_key in cache_keys)
        self.assertTrue(EventMatchesQuery('2015casj').cache_key in cache_keys)
        self.assertTrue(EventMatchesQuery('2015cama').cache_key in cache_keys)
        self.assertTrue(EventMatchesGdcvDataQuery('2015casj').cache_key in cache_keys)
        self.assertTrue(EventMatchesGdcvDataQuery('2015cama').cache_key in cache_keys)
        self.assertTrue(TeamEventMatchesQuery('frc254', '2015casj').cache_key in cache_keys)
        self.assertTrue(TeamEventMatchesQuery('frc254', '2015cama').cache_key in cache_keys)
        self.assertTrue(TeamEventMatchesQuery('frc604', '2015casj').cache_key in cache_keys)
        self.assertTrue(TeamEventMatchesQuery('frc604', '2015cama').cache_key in cache_keys)
        self.assertTrue(TeamYearMatchesQuery('frc254', 2014).cache_key in cache_keys)
        self.assertTrue(TeamYearMatchesQuery('frc254', 2015).cache_key in cache_keys)
        self.assertTrue(TeamYearMatchesQuery('frc604', 2014).cache_key in cache_keys)
        self.assertTrue(TeamYearMatchesQuery('frc604', 2015).cache_key in cache_keys)
Ejemplo n.º 2
0
    def get_match_cache_keys_and_controllers(cls, affected_refs):
        """
        Gets cache keys and controllers that references this match
        """
        match_keys = affected_refs['key']
        event_keys = affected_refs['event']
        team_keys = affected_refs['team_keys']
        years = affected_refs['year']

        return cls._get_match_cache_keys_and_controllers(match_keys) + \
            cls._get_matches_cache_keys_and_controllers(event_keys) + \
            cls._get_team_event_matches_cache_keys_and_controllers(team_keys, event_keys) + \
            cls._queries_to_cache_keys_and_controllers(get_affected_queries.match_updated(affected_refs))
Ejemplo n.º 3
0
    def get_match_cache_keys_and_controllers(cls, affected_refs):
        """
        Gets cache keys and controllers that references this match
        """
        match_keys = affected_refs['key']
        event_keys = affected_refs['event']
        team_keys = affected_refs['team_keys']
        years = affected_refs['year']

        return cls._get_match_cache_keys_and_controllers(match_keys) + \
            cls._get_matches_cache_keys_and_controllers(event_keys) + \
            cls._get_team_event_matches_cache_keys_and_controllers(team_keys, event_keys) + \
            cls._queries_to_cache_keys_and_controllers(get_affected_queries.match_updated(affected_refs))
    def test_match_updated(self):
        affected_refs = {
            'key':
            {ndb.Key(Match, '2015casj_qm1'),
             ndb.Key(Match, '2015casj_qm2')},
            'event': {ndb.Key(Event, '2015casj'),
                      ndb.Key(Event, '2015cama')},
            'team_keys': {ndb.Key(Team, 'frc254'),
                          ndb.Key(Team, 'frc604')},
            'year': {2014, 2015},
        }
        cache_keys = [
            q.cache_key
            for q in get_affected_queries.match_updated(affected_refs)
        ]

        self.assertEqual(len(cache_keys), 16)
        self.assertTrue(MatchQuery('2015casj_qm1').cache_key in cache_keys)
        self.assertTrue(MatchQuery('2015casj_qm2').cache_key in cache_keys)
        self.assertTrue(
            MatchGdcvDataQuery('2015casj_qm1').cache_key in cache_keys)
        self.assertTrue(
            MatchGdcvDataQuery('2015casj_qm2').cache_key in cache_keys)
        self.assertTrue(EventMatchesQuery('2015casj').cache_key in cache_keys)
        self.assertTrue(EventMatchesQuery('2015cama').cache_key in cache_keys)
        self.assertTrue(
            EventMatchesGdcvDataQuery('2015casj').cache_key in cache_keys)
        self.assertTrue(
            EventMatchesGdcvDataQuery('2015cama').cache_key in cache_keys)
        self.assertTrue(
            TeamEventMatchesQuery('frc254', '2015casj').cache_key in
            cache_keys)
        self.assertTrue(
            TeamEventMatchesQuery('frc254', '2015cama').cache_key in
            cache_keys)
        self.assertTrue(
            TeamEventMatchesQuery('frc604', '2015casj').cache_key in
            cache_keys)
        self.assertTrue(
            TeamEventMatchesQuery('frc604', '2015cama').cache_key in
            cache_keys)
        self.assertTrue(
            TeamYearMatchesQuery('frc254', 2014).cache_key in cache_keys)
        self.assertTrue(
            TeamYearMatchesQuery('frc254', 2015).cache_key in cache_keys)
        self.assertTrue(
            TeamYearMatchesQuery('frc604', 2014).cache_key in cache_keys)
        self.assertTrue(
            TeamYearMatchesQuery('frc604', 2015).cache_key in cache_keys)