def test_update_deliver_true_to_true(self): self.reading_item1.to_deliver = True self.reading_item1.save() request = self.factory.post(self.update_deliver, { 'to_deliver': 'true', 'permalink': self.reading_item1.article.permalink }) force_authenticate(request, user=self.test_user) response = update_deliver(request) self.assertEqual(response.status_code, status.HTTP_200_OK) my_article = Article.objects.get(permalink=self.reading_item1.article.permalink) updated_readinglist_item = ReadingListItem.objects.get(reader=self.test_user, article=my_article) self.assertTrue(updated_readinglist_item.to_deliver)
def test_update_deliver_over_page(self): self.assertFalse(self.reading_item1.to_deliver) request = self.factory.post(self.update_deliver, { 'to_deliver': 'true', 'permalink': self.reading_item1.article.permalink }) force_authenticate(request, user=self.test_user) for i in range(0, 9): my_article = baker.make('Article') my_article.page_count = 5 my_article.save() response = update_deliver(request) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertFalse(self.reading_item1.to_deliver)
def test_unauthenticated_update_deliver(self): """Checks that an unauthenticated update_deliver() request returns 403.""" request = self.factory.post(self.update_deliver) response = update_deliver(request) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)