def test_eventteam_updated(self):
        affected_refs = {
            'event': {ndb.Key(Event, '2015casj'), ndb.Key(Event, '2015cama')},
            'team': {ndb.Key(Team, 'frc254'), ndb.Key(Team, 'frc604')},
            'year': {2014, 2015}
        }
        cache_keys = [q.cache_key for q in get_affected_queries.eventteam_updated(affected_refs)]

        self.assertEqual(len(cache_keys), 18)
        self.assertTrue(TeamEventsQuery('frc254').cache_key in cache_keys)
        self.assertTrue(TeamEventsQuery('frc604').cache_key in cache_keys)
        self.assertTrue(TeamParticipationQuery('frc254').cache_key in cache_keys)
        self.assertTrue(TeamParticipationQuery('frc604').cache_key in cache_keys)
        self.assertTrue(TeamYearEventsQuery('frc254', 2014).cache_key in cache_keys)
        self.assertTrue(TeamYearEventsQuery('frc254', 2015).cache_key in cache_keys)
        self.assertTrue(TeamYearEventsQuery('frc604', 2014).cache_key in cache_keys)
        self.assertTrue(TeamYearEventsQuery('frc604', 2015).cache_key in cache_keys)
        self.assertTrue(TeamListYearQuery(2014, 0).cache_key in cache_keys)
        self.assertTrue(TeamListYearQuery(2014, 1).cache_key in cache_keys)
        self.assertTrue(TeamListYearQuery(2015, 0).cache_key in cache_keys)
        self.assertTrue(TeamListYearQuery(2015, 1).cache_key in cache_keys)
        self.assertTrue(EventTeamsQuery('2015casj').cache_key in cache_keys)
        self.assertTrue(EventTeamsQuery('2015cama').cache_key in cache_keys)
        self.assertTrue(EventTeamsMediasQuery('2015cama').cache_key in cache_keys)
        self.assertTrue(EventTeamsMediasQuery('2015casj').cache_key in cache_keys)
        self.assertTrue(EventTeamsPreferredMediasQuery('2015cama').cache_key in cache_keys)
        self.assertTrue(EventTeamsPreferredMediasQuery('2015casj').cache_key in cache_keys)
Esempio n. 2
0
    def test_eventteam_updated(self):
        affected_refs = {
            'event': {ndb.Key(Event, '2015casj'),
                      ndb.Key(Event, '2015cama')},
            'team': {ndb.Key(Team, 'frc254'),
                     ndb.Key(Team, 'frc604')},
            'year': {2014, 2015}
        }
        cache_keys = [
            q.cache_key
            for q in get_affected_queries.eventteam_updated(affected_refs)
        ]

        self.assertEqual(len(cache_keys), 14)
        self.assertTrue(TeamEventsQuery('frc254').cache_key in cache_keys)
        self.assertTrue(TeamEventsQuery('frc604').cache_key in cache_keys)
        self.assertTrue(
            TeamParticipationQuery('frc254').cache_key in cache_keys)
        self.assertTrue(
            TeamParticipationQuery('frc604').cache_key in cache_keys)
        self.assertTrue(
            TeamYearEventsQuery('frc254', 2014).cache_key in cache_keys)
        self.assertTrue(
            TeamYearEventsQuery('frc254', 2015).cache_key in cache_keys)
        self.assertTrue(
            TeamYearEventsQuery('frc604', 2014).cache_key in cache_keys)
        self.assertTrue(
            TeamYearEventsQuery('frc604', 2015).cache_key in cache_keys)
        self.assertTrue(TeamListYearQuery(2014, 0).cache_key in cache_keys)
        self.assertTrue(TeamListYearQuery(2014, 1).cache_key in cache_keys)
        self.assertTrue(TeamListYearQuery(2015, 0).cache_key in cache_keys)
        self.assertTrue(TeamListYearQuery(2015, 1).cache_key in cache_keys)
        self.assertTrue(EventTeamsQuery('2015casj').cache_key in cache_keys)
        self.assertTrue(EventTeamsQuery('2015cama').cache_key in cache_keys)
Esempio n. 3
0
    def get_eventteam_cache_keys_and_controllers(cls, affected_refs):
        """
        Gets cache keys and controllers that references this eventteam
        """
        event_keys = affected_refs['event']
        team_keys = affected_refs['team']
        years = affected_refs['year']

        return cls._get_eventteams_cache_keys_and_controllers(event_keys) + \
            cls._get_team_events_cache_keys_and_controllers(team_keys, years) + \
            cls._get_team_years_participated_cache_keys_and_controllers(team_keys) + \
            cls._queries_to_cache_keys_and_controllers(get_affected_queries.eventteam_updated(affected_refs))
    def get_eventteam_cache_keys_and_controllers(cls, affected_refs):
        """
        Gets cache keys and controllers that references this eventteam
        """
        event_keys = affected_refs['event']
        team_keys = affected_refs['team']
        years = affected_refs['year']

        return cls._get_eventteams_cache_keys_and_controllers(event_keys) + \
            cls._get_team_events_cache_keys_and_controllers(team_keys, years) + \
            cls._get_team_years_participated_cache_keys_and_controllers(team_keys) + \
            cls._queries_to_cache_keys_and_controllers(get_affected_queries.eventteam_updated(affected_refs))