def test_next_prev_year(self): '''Test the yearly next/previous links are correct.''' # Add a couple of older entries as well as the two in test_data. e1 = Entry(title='Entry in Aug 2009', body='test', blog_id=1, published_date='2009-08-15 10:00:00', author_id=1) e1.save() e2 = Entry(title='Entry in Dec 2007', body='test', blog_id=1, published_date='2007-12-15 10:00:00', author_id=1) e2.save() c = Client() response = c.get('/writing/2010/') self.failUnlessEqual(response.status_code, 200) self.failUnlessEqual(response.context['previous_year_correct'], datetime.datetime(year=2009,month=8,day=15,hour=10,minute=0,second=0)) self.failUnlessEqual(response.context['next_year_correct'], None) response = c.get('/writing/2009/') self.failUnlessEqual(response.status_code, 200) self.failUnlessEqual(response.context['previous_year_correct'], datetime.datetime(year=2007,month=12,day=15,hour=10,minute=0,second=0)) self.failUnlessEqual(response.context['next_year_correct'], datetime.datetime(year=2010,month=9,day=26,hour=15,minute=53,second=45)) response = c.get('/writing/2007/') self.failUnlessEqual(response.status_code, 200) self.failUnlessEqual(response.context['previous_year_correct'], None) self.failUnlessEqual(response.context['next_year_correct'], datetime.datetime(year=2009,month=8,day=15,hour=10,minute=0,second=0)) e1.delete() e2.delete()
def test_htmlize(self): '''Make sure the three different kinds of formatting the entry body/body_more work.''' entry = Entry() entry.body = """Hello *there*. How are you?""" entry.format = entry.NO_FORMAT formatted_body = entry.htmlize_text(entry.body) self.assertEquals(formatted_body, u"""Hello *there*. How are you?""") entry.format = entry.CONVERT_LINE_BREAKS_FORMAT formatted_body = entry.htmlize_text(entry.body) self.assertEquals(formatted_body, u"""<p>Hello *there*. <br /> How are you?</p>""") entry.format = entry.MARKDOWN_FORMAT formatted_body = entry.htmlize_text(entry.body) self.assertEquals(formatted_body, u"""<p>Hello <em>there</em>.<br /> How are you?</p>""")