def test_double_finish(self): # validate that finish called twice acts as expected feed = DatabaseFallbackLoveFeed(self.bogus_user.id) feed.delete() feed.finish() feed.finish() self.assertEqual(feed.count(), 1)
def test_empty_redis(self): # hack to make sure our queries work feed = DatabaseFallbackLoveFeed(self.bogus_user.id) feed.delete() # test the basic scenario if we have no data results = feed[:1] self.assertNotEqual(results, []) self.assertEqual(feed.source, 'db') results = feed[:1] self.assertEqual(feed.source, 'redis') # reset and test a finished empty list, this shouldnt return anything feed.delete() feed.finish() results = feed[:1] self.assertEqual(results, []) # try again past the first page feed.delete() results = feed[:1] results = feed[:2] self.assertEqual(len(results), 2) self.assertEqual(feed.source, 'db')