From bf21d8dac43d07e5912d3689f593f755965e899b Mon Sep 17 00:00:00 2001 From: Kevin Diale Date: Fri, 2 Aug 2013 15:13:07 -0400 Subject: [PATCH] Adding tests for unselected actions. --- example/blog/tests/test_views.py | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/example/blog/tests/test_views.py b/example/blog/tests/test_views.py index 9aee126..a91c3eb 100644 --- a/example/blog/tests/test_views.py +++ b/example/blog/tests/test_views.py @@ -269,6 +269,43 @@ class PostListTest(BaseIntegrationTest): model_admin.ordering, ) + def test_all_unselected_action(self): + self._create_posts() + + response = self.client.get(reverse("admin2:blog_post_index")) + + self.assertTrue(all([ + not post.published + for post in response.context["object_list"] + ])) + + response = self.client.post( + reverse("admin2:blog_post_index"), + { + 'action': 'PublishAllItemsAction', + }, + follow=True + ) + + self.assertTrue(all([ + post.published + for post in response.context["object_list"] + ])) + + # Test function-based view + response = self.client.post( + reverse("admin2:blog_post_index"), + { + 'action': 'PublishAllItemsAction', + }, + follow=True, + ) + + self.assertTrue(all([ + post.published + for post in response.context["object_list"] + ])) + class PostListTestCustomAction(BaseIntegrationTest):