def setUp(self): """override one in unittest.TestCase""" write_test_profile() self.blog = Blogs() self.blog.add_blog(u"first blog", PROFILE_TEST) self.blog.add_blog(u"second blog", PROFILE_TEST) self.blog.add_comment(0, u"commenting the first", PSEUDO)
class BlogTest(unittest.TestCase): """Test Blog behaviour""" def setUp(self): """override one in unittest.TestCase""" write_test_profile() self.blog = Blogs() self.blog.add_blog(u"first blog", PROFILE_TEST) self.blog.add_blog(u"second blog", PROFILE_TEST) self.blog.add_comment(0, u"commenting the first", PSEUDO) def test_blog(self): self.assertEquals(self.blog.count_blogs(), 2) self.assertEquals(self.blog.get_blog(0).text, u"first blog") self.assertEquals(self.blog.get_blog(0).count_blogs(), 1) self.assertEquals(self.blog.get_blog(1).text, u"second blog") self.assertEquals(self.blog.get_blog(1).count_blogs(), 0) def test_copy(self): copied_blog = self.blog.copy() # add some blogs in first self.blog.add_blog(u"more blog", PROFILE_TEST) self.blog.add_comment(0, u"commenting (again) the first", PSEUDO) # check result self.assertEquals(self.blog.count_blogs(), 3) self.assertEquals(self.blog.get_blog(0).count_blogs(), 2) # check copy self.assertEquals(copied_blog.count_blogs(), 2) self.assertEquals(copied_blog.get_blog(0).text, u"first blog") self.assertEquals(copied_blog.get_blog(0).count_blogs(), 1) self.assertEquals(copied_blog.get_blog(1).text, u"second blog") self.assertEquals(copied_blog.get_blog(1).count_blogs(), 0) def test_load(self): loaded_blog = load_blogs(FILE_TEST + BLOG_EXT) self.assertEquals(loaded_blog.count_blogs(), 1) self.assertEquals(loaded_blog.get_blog(0).text, u"This is a test") self.assertEquals(loaded_blog.get_blog(0).count_blogs(), 0) def test_retro_compatibility(self): loaded_blog = load_blogs(os.path.join(PROFILE_DIR, PROFILE_010 + BLOG_EXT)) self.assertEquals(loaded_blog.count_blogs(), 4) self.assertEquals(loaded_blog.get_blog(0).text, u"Hi there! Watch my next movie... it's going to be real fun") self.assertEquals(loaded_blog.get_blog(0).count_blogs(), 0) self.assertEquals(loaded_blog.get_blog(1).text, u"I won't tell you much but this I can say: it's going to be terrific!") self.assertEquals(loaded_blog.get_blog(2).text, u'Watch here for its name... coming soon') self.assertEquals(loaded_blog.get_blog(3).text, u"A Godess' world. What do you think?")