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)