Exemple #1
0
    def gen_keys():
        yield promoted_memo_key

        # just let this one do its own writing
        load_all_reddits()

        yield queries.get_all_comments().iden

        l_q = Link._query(Link.c._spam == (True, False),
                          Link.c._deleted == (True, False),
                          sort=desc('_date'),
                          data=True,
                          )
        for link in fetch_things2(l_q, verbosity):
            yield comments_key(link._id)
            yield last_modified_key(link, 'comments')

        a_q = Account._query(Account.c._spam == (True, False),
                             sort=desc('_date'),
                             )
        for account in fetch_things2(a_q, verbosity):
            yield messages_key(account._id)
            yield last_modified_key(account, 'overview')
            yield last_modified_key(account, 'commented')
            yield last_modified_key(account, 'submitted')
            yield last_modified_key(account, 'liked')
            yield last_modified_key(account, 'disliked')
            yield queries.get_comments(account, 'new', 'all').iden
            yield queries.get_submitted(account, 'new', 'all').iden
            yield queries.get_liked(account).iden
            yield queries.get_disliked(account).iden
            yield queries.get_hidden(account).iden
            yield queries.get_saved(account).iden
            yield queries.get_inbox_messages(account).iden
            yield queries.get_unread_messages(account).iden
            yield queries.get_inbox_comments(account).iden
            yield queries.get_unread_comments(account).iden
            yield queries.get_inbox_selfreply(account).iden
            yield queries.get_unread_selfreply(account).iden
            yield queries.get_sent(account).iden

        sr_q = Subreddit._query(Subreddit.c._spam == (True, False),
                                sort=desc('_date'),
                                )
        for sr in fetch_things2(sr_q, verbosity):
            yield last_modified_key(sr, 'stylesheet_contents')
            yield queries.get_links(sr, 'hot', 'all').iden
            yield queries.get_links(sr, 'new', 'all').iden

            for sort in 'top', 'controversial':
                for time in 'hour', 'day', 'week', 'month', 'year', 'all':
                    yield queries.get_links(sr, sort, time,
                                            merge_batched=False).iden
            yield queries.get_spam_links(sr).iden
            yield queries.get_spam_comments(sr).iden
            yield queries.get_reported_links(sr).iden
            yield queries.get_reported_comments(sr).iden
            yield queries.get_subreddit_messages(sr).iden
            yield queries.get_unread_subreddit_messages(sr).iden
Exemple #2
0
    def gen_keys():
        yield promoted_memo_key

        # just let this one do its own writing
        load_all_reddits()

        yield queries.get_all_comments().iden

        l_q = Link._query(Link.c._spam == (True, False),
                          Link.c._deleted == (True, False),
                          sort=desc('_date'),
                          data=True,
                          )
        for link in fetch_things2(l_q, verbosity):
            yield comments_key(link._id)
            yield last_modified_key(link, 'comments')

        a_q = Account._query(Account.c._spam == (True, False),
                             sort=desc('_date'),
                             )
        for account in fetch_things2(a_q, verbosity):
            yield messages_key(account._id)
            yield last_modified_key(account, 'overview')
            yield last_modified_key(account, 'commented')
            yield last_modified_key(account, 'submitted')
            yield last_modified_key(account, 'liked')
            yield last_modified_key(account, 'disliked')
            yield queries.get_comments(account, 'new', 'all').iden
            yield queries.get_submitted(account, 'new', 'all').iden
            yield queries.get_liked(account).iden
            yield queries.get_disliked(account).iden
            yield queries.get_hidden(account).iden
            yield queries.get_saved(account).iden
            yield queries.get_inbox_messages(account).iden
            yield queries.get_unread_messages(account).iden
            yield queries.get_inbox_comments(account).iden
            yield queries.get_unread_comments(account).iden
            yield queries.get_inbox_selfreply(account).iden
            yield queries.get_unread_selfreply(account).iden
            yield queries.get_sent(account).iden

        sr_q = Subreddit._query(Subreddit.c._spam == (True, False),
                                sort=desc('_date'),
                                )
        for sr in fetch_things2(sr_q, verbosity):
            yield last_modified_key(sr, 'stylesheet_contents')
            yield queries.get_links(sr, 'hot', 'all').iden
            yield queries.get_links(sr, 'new', 'all').iden

            for sort in 'top', 'controversial':
                for time in 'hour', 'day', 'week', 'month', 'year', 'all':
                    yield queries.get_links(sr, sort, time,
                                            merge_batched=False).iden
            yield queries.get_spam_links(sr).iden
            yield queries.get_spam_comments(sr).iden
            yield queries.get_reported_links(sr).iden
            yield queries.get_reported_comments(sr).iden
            yield queries.get_subreddit_messages(sr).iden
            yield queries.get_unread_subreddit_messages(sr).iden
Exemple #3
0
 def test_load_quarantined(self, _set_values, utils):
     """
     Assert `_set_values` never called when subreddit is quarantined.
     """
     self.default_subreddit.quarantined = True
     utils.fetch_things2.return_value = [self.default_subreddit]
     load_all_reddits()
     _set_values.assert_not_called()
Exemple #4
0
 def test_load_default(self, _set_values, utils):
     """
     Assert (`name`, False, False) passed by default.
     """
     utils.fetch_things2.return_value = [self.default_subreddit]
     load_all_reddits()
     expected_calls = self._expected_calls(False, False)
     _set_values.assert_has_calls(expected_calls, any_order=True)
 def test_load_quarantined(self, _set_values, utils):
     """
     Assert `_set_values` never called when subreddit is quarantined.
     """
     self.default_subreddit.quarantined = True
     utils.fetch_things2.return_value = [self.default_subreddit]
     load_all_reddits()
     _set_values.assert_not_called()
 def test_load_default(self, _set_values, utils):
     """
     Assert (`name`, False, False) passed by default.
     """
     utils.fetch_things2.return_value = [self.default_subreddit]
     load_all_reddits()
     expected_calls = self._expected_calls(False, False)
     _set_values.assert_has_calls(expected_calls, any_order=True)
Exemple #7
0
 def test_load_hide_ads_on_blacklist(self, _set_values, utils):
     """
     Assert (`name`, False, True) passed when name on anti_ads_subreddits.
     """
     g.live_config['anti_ads_subreddits'] = ['foo']
     utils.fetch_things2.return_value = [self.default_subreddit]
     load_all_reddits()
     expected_calls = self._expected_calls(False, True)
     _set_values.assert_has_calls(expected_calls, any_order=True)
Exemple #8
0
 def test_load_not_hide_ads(self, _set_values, utils):
     """
     Assert (`name`, False, True) passed when hide_ads is True.
     """
     self.default_subreddit.hide_ads = True
     utils.fetch_things2.return_value = [self.default_subreddit]
     load_all_reddits()
     expected_calls = self._expected_calls(False, True)
     _set_values.assert_has_calls(expected_calls, any_order=True)
 def test_load_hide_ads_on_blacklist(self, _set_values, utils):
     """
     Assert (`name`, False, True) passed when name on anti_ads_subreddits.
     """
     g.live_config['anti_ads_subreddits'] = ['foo']
     utils.fetch_things2.return_value = [self.default_subreddit]
     load_all_reddits()
     expected_calls = self._expected_calls(False, True)
     _set_values.assert_has_calls(expected_calls, any_order=True)
 def test_load_not_hide_ads(self, _set_values, utils):
     """
     Assert (`name`, False, True) passed when hide_ads is True.
     """
     self.default_subreddit.hide_ads = True
     utils.fetch_things2.return_value = [self.default_subreddit]
     load_all_reddits()
     expected_calls = self._expected_calls(False, True)
     _set_values.assert_has_calls(expected_calls, any_order=True)
Exemple #11
0
    def gen_keys():
        yield promoted_memo_key

        # just let this one do its own writing
        load_all_reddits()

        yield queries.get_all_comments().iden

        l_q = Link._query(
            Link.c._spam == (True, False), Link.c._deleted == (True, False), sort=desc("_date"), data=True
        )
        for link in fetch_things2(l_q, verbosity):
            yield comments_key(link._id)
            yield last_modified_key(link, "comments")

        a_q = Account._query(Account.c._spam == (True, False), sort=desc("_date"))
        for account in fetch_things2(a_q, verbosity):
            yield messages_key(account._id)
            yield last_modified_key(account, "overview")
            yield last_modified_key(account, "commented")
            yield last_modified_key(account, "submitted")
            yield last_modified_key(account, "liked")
            yield last_modified_key(account, "disliked")
            yield queries.get_comments(account, "new", "all").iden
            yield queries.get_submitted(account, "new", "all").iden
            yield queries.get_liked(account).iden
            yield queries.get_disliked(account).iden
            yield queries.get_hidden(account).iden
            yield queries.get_saved(account).iden
            yield queries.get_inbox_messages(account).iden
            yield queries.get_unread_messages(account).iden
            yield queries.get_inbox_comments(account).iden
            yield queries.get_unread_comments(account).iden
            yield queries.get_inbox_selfreply(account).iden
            yield queries.get_unread_selfreply(account).iden
            yield queries.get_sent(account).iden

        sr_q = Subreddit._query(Subreddit.c._spam == (True, False), sort=desc("_date"))
        for sr in fetch_things2(sr_q, verbosity):
            yield last_modified_key(sr, "stylesheet_contents")
            yield queries.get_links(sr, "hot", "all").iden
            yield queries.get_links(sr, "new", "all").iden

            for sort in "top", "controversial":
                for time in "hour", "day", "week", "month", "year", "all":
                    yield queries.get_links(sr, sort, time, merge_batched=False).iden
            yield queries.get_spam_links(sr).iden
            yield queries.get_spam_comments(sr).iden
            yield queries.get_reported_links(sr).iden
            yield queries.get_reported_comments(sr).iden
            yield queries.get_subreddit_messages(sr).iden
            yield queries.get_unread_subreddit_messages(sr).iden