Beispiel #1
0
 def setUp(self):
     """Create articles for the tests"""
     ArticleFactory.create_batch(
         2,
         publish=True,
         pub_date=datetime(1999, 1, 1, 12, 12, tzinfo=pytz.utc),
     )
     ArticleFactory(publish=True,
                    pub_date=datetime(1999, 1, 2, 12, tzinfo=pytz.utc))
     ArticleFactory(publish=True,
                    pub_date=datetime(1999, 2, 3, 12, tzinfo=pytz.utc))
     ArticleFactory(publish=True,
                    pub_date=datetime(2000, 6, 6, tzinfo=pytz.utc))
Beispiel #2
0
 def test_news_archive_author(self):
     """Should return all articles for the given author"""
     author = UserFactory()
     ArticleFactory.create_batch(
         3,
         publish=True,
         authors=[author],
         pub_date=timezone.now() - timedelta(1),
     )
     response = get_allowed(
         self.client,
         reverse('news-author', kwargs={
             'username': author.username
         })
     )
     eq_(
         len(response.context['object_list']),
         Article.objects.filter(authors=author).count()
     )