def test_1970_quote(self): """Check whether a quote from 1970-1-1 is marked as date_available=False.""" q = models.Quote() q.lecturer = baker.make(models.Lecturer) q.author = baker.make(User) q.quote = "spam" q.comment = "ham" q.date = datetime.datetime(1970, 1, 1) assert not q.date_available()
def test1970Quote(self): """Check whether a quote from 1970-1-1 is marked as date_available=False.""" q = models.Quote() q.lecturer = mommy.make(models.Lecturer) q.author = mommy.make(User) q.quote = 'spam' q.comment = 'ham' q.date = datetime.datetime(1970, 1, 1) self.assertFalse(q.date_available())
def test_null_value_author(self): q = models.Quote() q.lecturer = baker.make(models.Lecturer) q.quote = "spam" q.comment = "ham" try: q.save() except IntegrityError: pytest.fail( "A quote with no author should not throw an IntegrityError.")
def testNullValueAuthor(self): q = models.Quote() q.lecturer = mommy.make(models.Lecturer) q.quote = 'spam' q.comment = 'ham' try: q.save() except IntegrityError: self.fail( "A quote with no author should not throw an IntegrityError.")
def testQuote(self): quote = "Dies ist ein längeres Zitat, das dazu dient, zu testen " + \ "ob man Zitate erfassen kann und ob die Länge des Zitats mehr " + \ "als 255 Zeichen enthalten darf. Damit kann man sicherstellen, " + \ "dass im Model kein CharField verwendet wurde. Denn wir wollen " + \ "ja nicht, dass längere Zitate hier keinen Platz haben :)" before = datetime.datetime.now() q = models.Quote() q.author = mommy.make(User) q.lecturer = mommy.make(models.Lecturer) q.quote = quote q.comment = "Eine Bemerkung zum Kommentar" q.save() after = datetime.datetime.now() self.assertTrue(before < q.date < after) self.assertTrue(q.date_available())