def test_media_updated(self):
        affected_refs = {
            'references': {ndb.Key(Team, 'frc254'),
                           ndb.Key(Team, 'frc604')},
            'year': {2014, 2015},
        }
        cache_keys = [
            q.cache_key
            for q in get_affected_queries.media_updated(affected_refs)
        ]

        self.assertEqual(len(cache_keys), 10)
        self.assertTrue(
            TeamYearMediaQuery('frc254', 2014).cache_key in cache_keys)
        self.assertTrue(
            TeamYearMediaQuery('frc254', 2015).cache_key in cache_keys)
        self.assertTrue(TeamSocialMediaQuery('frc254').cache_key in cache_keys)
        self.assertTrue(
            TeamYearMediaQuery('frc604', 2014).cache_key in cache_keys)
        self.assertTrue(
            TeamYearMediaQuery('frc604', 2015).cache_key in cache_keys)
        self.assertTrue(TeamSocialMediaQuery('frc604').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)
    def get_media_cache_keys_and_controllers(cls, affected_refs):
        """
        Gets cache keys and controllers that reference this media
        """
        reference_keys = affected_refs['references']
        years = affected_refs['year']

        return cls._get_media_cache_keys_and_controllers(reference_keys, years) + \
            cls._queries_to_cache_keys_and_controllers(get_affected_queries.media_updated(affected_refs))
    def test_media_updated_event(self):
        affected_refs = {
            'references': {ndb.Key(Event, '2016necmp')},
            'year': {2016},
        }
        cache_keys = [q.cache_key for q in get_affected_queries.media_updated(affected_refs)]

        self.assertEqual(len(cache_keys), 1)
        self.assertTrue(EventMediasQuery('2016necmp').cache_key in cache_keys)
Example #4
0
    def get_media_cache_keys_and_controllers(cls, affected_refs):
        """
        Gets cache keys and controllers that reference this media
        """
        reference_keys = affected_refs['references']
        years = affected_refs['year']

        return cls._get_media_cache_keys_and_controllers(reference_keys, years) + \
            cls._queries_to_cache_keys_and_controllers(get_affected_queries.media_updated(affected_refs))
    def test_media_updated_event(self):
        affected_refs = {
            'references': {ndb.Key(Event, '2016necmp')},
            'year': {2016},
            'media_tag_enum': {None, None}
        }
        cache_keys = [q.cache_key for q in get_affected_queries.media_updated(affected_refs)]

        self.assertEqual(len(cache_keys), 1)
        self.assertTrue(EventMediasQuery('2016necmp').cache_key in cache_keys)
Example #6
0
    def get_media_cache_keys_and_controllers(cls, affected_refs):
        """
        Gets cache keys and controllers that reference this media
        """
        reference_keys = affected_refs['references']
        years = affected_refs['year']
        media_tag_enums = affected_refs['media_tag_enum']

        tags = map(lambda media_tag_enum: MediaTag.tag_url_names[media_tag_enum], media_tag_enums)

        return cls._get_media_cache_keys_and_controllers(reference_keys, years, tags) + \
            cls._queries_to_cache_keys_and_controllers(get_affected_queries.media_updated(affected_refs))
    def test_media_updated(self):
        affected_refs = {
            'references': {ndb.Key(Team, 'frc254'), ndb.Key(Team, 'frc604')},
            'year': {2014, 2015},
        }
        cache_keys = [q.cache_key for q in get_affected_queries.media_updated(affected_refs)]

        self.assertEqual(len(cache_keys), 4)
        self.assertTrue(TeamYearMediaQuery('frc254', 2014).cache_key in cache_keys)
        self.assertTrue(TeamYearMediaQuery('frc254', 2015).cache_key in cache_keys)
        self.assertTrue(TeamYearMediaQuery('frc604', 2014).cache_key in cache_keys)
        self.assertTrue(TeamYearMediaQuery('frc604', 2015).cache_key in cache_keys)
    def test_media_updated_team(self):
        affected_refs = {
            'references': {ndb.Key(Team, 'frc254'), ndb.Key(Team, 'frc604')},
            'year': {2014, 2015},
        }
        cache_keys = [q.cache_key for q in get_affected_queries.media_updated(affected_refs)]

        self.assertEqual(len(cache_keys), 10)
        self.assertTrue(TeamYearMediaQuery('frc254', 2014).cache_key in cache_keys)
        self.assertTrue(TeamYearMediaQuery('frc254', 2015).cache_key in cache_keys)
        self.assertTrue(TeamSocialMediaQuery('frc254').cache_key in cache_keys)
        self.assertTrue(TeamYearMediaQuery('frc604', 2014).cache_key in cache_keys)
        self.assertTrue(TeamYearMediaQuery('frc604', 2015).cache_key in cache_keys)
        self.assertTrue(TeamSocialMediaQuery('frc604').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)
    def test_media_updated_team(self):
        affected_refs = {
            'references': {ndb.Key(Team, 'frc254'),
                           ndb.Key(Team, 'frc604')},
            'year': {2014, 2015},
            'media_tag_enum':
            {MediaTag.CHAIRMANS_ESSAY, MediaTag.CHAIRMANS_VIDEO},
        }
        cache_keys = [
            q.cache_key
            for q in get_affected_queries.media_updated(affected_refs)
        ]

        self.assertEqual(len(cache_keys), 22)
        self.assertTrue(
            TeamYearMediaQuery('frc254', 2014).cache_key in cache_keys)
        self.assertTrue(
            TeamYearMediaQuery('frc254', 2015).cache_key in cache_keys)
        self.assertTrue(TeamSocialMediaQuery('frc254').cache_key in cache_keys)
        self.assertTrue(
            TeamYearMediaQuery('frc604', 2014).cache_key in cache_keys)
        self.assertTrue(
            TeamYearMediaQuery('frc604', 2015).cache_key in cache_keys)
        self.assertTrue(TeamSocialMediaQuery('frc604').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)
        self.assertTrue(
            TeamTagMediasQuery('frc254', MediaTag.CHAIRMANS_ESSAY).cache_key in
            cache_keys)
        self.assertTrue(
            TeamTagMediasQuery('frc604', MediaTag.CHAIRMANS_VIDEO).cache_key in
            cache_keys)
        self.assertTrue(
            TeamYearTagMediasQuery('frc254', MediaTag.CHAIRMANS_ESSAY,
                                   2014).cache_key in cache_keys)
        self.assertTrue(
            TeamYearTagMediasQuery('frc604', MediaTag.CHAIRMANS_VIDEO,
                                   2015).cache_key in cache_keys)
    def test_media_updated_team(self):
        affected_refs = {
            'references': {ndb.Key(Team, 'frc254'), ndb.Key(Team, 'frc604')},
            'year': {2014, 2015},
            'media_tag_enum': {MediaTag.CHAIRMANS_ESSAY, MediaTag.CHAIRMANS_VIDEO},
        }
        cache_keys = [q.cache_key for q in get_affected_queries.media_updated(affected_refs)]

        self.assertEqual(len(cache_keys), 22)
        self.assertTrue(TeamYearMediaQuery('frc254', 2014).cache_key in cache_keys)
        self.assertTrue(TeamYearMediaQuery('frc254', 2015).cache_key in cache_keys)
        self.assertTrue(TeamSocialMediaQuery('frc254').cache_key in cache_keys)
        self.assertTrue(TeamYearMediaQuery('frc604', 2014).cache_key in cache_keys)
        self.assertTrue(TeamYearMediaQuery('frc604', 2015).cache_key in cache_keys)
        self.assertTrue(TeamSocialMediaQuery('frc604').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)
        self.assertTrue(TeamTagMediasQuery('frc254', MediaTag.CHAIRMANS_ESSAY).cache_key in cache_keys)
        self.assertTrue(TeamTagMediasQuery('frc604', MediaTag.CHAIRMANS_VIDEO).cache_key in cache_keys)
        self.assertTrue(TeamYearTagMediasQuery('frc254', MediaTag.CHAIRMANS_ESSAY, 2014).cache_key in cache_keys)
        self.assertTrue(TeamYearTagMediasQuery('frc604', MediaTag.CHAIRMANS_VIDEO, 2015).cache_key in cache_keys)