Ejemplo n.º 1
0
    def test_get_files(self):
        from r2.lib.db import queries
        from r2.models import Subreddit, Account, Link, Thing

        account = Account._byID(1, data=True)
        sr = Subreddit._by_name("reddit_test0")
        link_url = self.make_unique_url()

        new_link = Link._submit("test_get_files", link_url, account, sr, "127.0.0.1", kind="file")
        queries.new_link(new_link, foreground=True)

        # make sure it returns like a normal link
        res = Thing._by_fullname(queries.get_links(sr, "new", "all"), return_dict=False)
        self.assert_true(len(res) > 0, "no links returned")
        self.assert_equal(new_link._id, res[0]._id)

        # should return with a kind = 'file' filter
        res = list(queries.get_files(sr))
        self.assert_true(len(res) > 0, "no links returned")
        self.assert_equal(new_link._id, res[0]._id)
Ejemplo n.º 2
0
 def get_files(self, time):
     from r2.lib.db import queries
     return queries.get_files(self, time)