예제 #1
0
파일: test_news.py 프로젝트: agripo/website
 def test_cant_publish_two_news_at_the_same_time(self):
     user = self._create_user().add_to_managers()
     pub = datetime.date.today() - datetime.timedelta(1)
     n = News(title="Title", content="Content", writer=user, publication_date=pub)
     n.save()
     n2 = News(title="Title", content="Content", writer=user, publication_date=pub)
     self.assertRaises(IntegrityError, n2.save)
예제 #2
0
파일: test_news.py 프로젝트: agripo/website
 def test_news_icon_defaults_to_(self):
     user = self._create_user().add_to_managers()
     pub = datetime.date.today() - datetime.timedelta(1)
     n = News(title="Title", content="Content", writer=user, publication_date=pub)
     n.save()  # should not raise
     icon = Icon.objects.get(icon="comment")
     self.assertEqual(n.icon, icon)
예제 #3
0
파일: test_news.py 프로젝트: agripo/website
    def _create_news(self, user=None, save=True, in_the_past=False):
        if not user:
            user = self._create_user().add_to_managers()

        if in_the_past:
            original_datetime = datetime.date
            datetime.date = MockToday

        news = News(title="Some random title", content="And some random content", writer=user)
        if save:
            news.save()
        else:
            news.full_clean()

        if in_the_past:
            datetime.date = original_datetime

        return news
예제 #4
0
파일: test_news.py 프로젝트: agripo/website
 def test_news_can_have_an_icon(self):
     user = self._create_user().add_to_managers()
     pub = datetime.date.today() - datetime.timedelta(1)
     icon = Icon.objects.get(icon="star")
     n = News(title="Title", content="Content", writer=user, publication_date=pub, icon=icon)
     n.save()  # should not raise
예제 #5
0
def last_news_box(request):
    return {'last_news': News.get_last()}