def test_get_reviews(self): username = '******' reviews = model_access.get_reviews(username) self.assertTrue(len(reviews) > 1) # we should have at least one review from Air Mail and one from # bread basket listings_with_reviews = [i.listing.title for i in reviews] self.assertTrue('Air Mail' in listings_with_reviews) self.assertTrue('Bread Basket' in listings_with_reviews) # now make a request with a user that doesn't have access to # Bread Basket username = '******' reviews = model_access.get_reviews(username) self.assertTrue(len(reviews) > 1) # make sure Air Mail is present but not Bread Basket listings_with_reviews = [i.listing.title for i in reviews] self.assertTrue('Air Mail' in listings_with_reviews) self.assertTrue('Bread Basket' not in listings_with_reviews)
def get_queryset(self): return model_access.get_reviews(self.request.user.username)