Beispiel #1
0
 def setUp(self):
     # Create a dummy user, category, and two articles for testing
     self.user = dummy_user()
     self.category = dummy_category()
     self.article1 = dummy_article(self.user, self.category, Article.PUBLISHED)
     self.article2 = dummy_article(self.user, self.category, Article.PUBLISHED)
     # Make the second article older so that the first one always sorts first
     self.article2.date -= timedelta(0, 1)
     self.article2.save()
Beispiel #2
0
 def setUp(self):
     # Create a dummy user, category, and two articles for testing
     self.user = dummy_user()
     self.category = dummy_category()
     self.article1 = dummy_article(self.user, self.category,
                                   Article.PUBLISHED)
     self.article2 = dummy_article(self.user, self.category,
                                   Article.PUBLISHED)
     # Make the second article older so that the first one always sorts first
     self.article2.date -= timedelta(0, 1)
     self.article2.save()
Beispiel #3
0
 def test_access_to_published_article(self):
     article = dummy_article(self.user1, self.category, Article.PUBLISHED)
     self.check_permission(article, AnonymousUser(), True)
     self.check_permission(article, self.user1, True)
     self.check_permission(article, self.user2, True)
     self.check_permission(article, self.admin, True)
Beispiel #4
0
 def test_access_to_unapproved_article(self):
     article = dummy_article(self.user1, self.category, Article.UNAPPROVED)
     self.check_permission(article, AnonymousUser(), False)
     self.check_permission(article, self.user1, True)
     self.check_permission(article, self.user2, False)
     self.check_permission(article, self.admin, True)
Beispiel #5
0
 def test_access_to_draft_article(self):
     article = dummy_article(self.user1, self.category, Article.DRAFT)
     self.check_permission(article, AnonymousUser(), False)
     self.check_permission(article, self.user1, True)
     self.check_permission(article, self.user2, False)
     self.check_permission(article, self.admin, True)