Example #1
0
  def test_ordering(self):
    self.BlogPost.objects.create(text="foo", posted_at=datetime.datetime(1985, 9, 19, 18, 30))
    self.BlogPost.objects.create(text="bar", posted_at=datetime.datetime(1985, 9, 19, 19, 30))
    c = Client()
    response = c.get("/index/")
    c = response.content.decode("utf-8")
    self.assertNotIn('No posts to show', c, "Jeśli są posty do pokazania to napis 'no posts to show' nie powinien się pojawiać" )
    self.assertIn('foo', c, "Treści postów powinny pojawiać się na stronie")
    self.assertIn('bar', c, "Treści postów powinny pojawiać się na stronie")

    self.assertLess(c.index('bar'), c.index('foo'), "Starszy post powinien pojawiać się pod młodszym")