Example #1
0
 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)
Example #2
0
 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)
Example #3
0
    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
Example #4
0
 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