def test_update_then_save(self):
        cda = CommentDataAccess("test.ini")
        cda.load()
        c = Comment()
        c.set_id("id1")
        c.set_time(2015, 1, 1, 1)
        c.set_message("message0")
        c.set_user_id("user0")
        self.assertTrue(cda.update_comment(c))
        cda.save()

        with open("test.ini", "rt") as f:
            self.assertEqual(f.readline(), "[id1]\n")
            self.assertEqual(f.readline(), "time = 01/01/15 01:00:00\n")
            self.assertEqual(f.readline(), "user id = user0\n")
            self.assertEqual(f.readline(), "message = message0\n")

            self.assertEqual(f.readline(), "\n")

            self.assertEqual(f.readline(), "[id2]\n")
            self.assertEqual(f.readline(), "time = 06/10/15 12:00:00\n")
            self.assertEqual(f.readline(), "user id = user2\n")
            self.assertEqual(f.readline(), "message = message2\n")

            self.assertEqual(f.readline(), "\n")

            self.assertEqual(f.readline(), "[id3]\n")
            self.assertEqual(f.readline(), "time = 06/11/15 12:00:00\n")
            self.assertEqual(f.readline(), "user id = user3\n")
            self.assertEqual(f.readline(), "message = message3\n")

            self.assertEqual(f.readline(), "\n")
            self.assertEqual(f.readline(), "")
    def test_update_then_list(self):
        cda = CommentDataAccess("test.ini")
        cda.load()
        c = Comment()
        c.set_id("id1")
        c.set_time(2015, 1, 1, 1)
        c.set_message("message0")
        c.set_user_id("user0")
        self.assertTrue(cda.update_comment(c))
        clist = cda.list_all_comments()
        
        self.assertEqual(len(clist), 3)

        c = clist[0]
        self.assertEqual(c.get_id(), "id1")
        self.assertEqual(c.get_user_id(), "user0")
        self.assertEqual(c.get_message(), "message0")
        self.assertEqual(c.get_time(), datetime.datetime(2015, 1, 1, 1))

        c = clist[1]
        self.assertEqual(c.get_id(), "id2")
        self.assertEqual(c.get_user_id(), "user2")
        self.assertEqual(c.get_message(), "message2")
        self.assertEqual(c.get_time(), datetime.datetime(2015, 6, 10, 12))

        c = clist[2]
        self.assertEqual(c.get_id(), "id3")
        self.assertEqual(c.get_user_id(), "user3")
        self.assertEqual(c.get_message(), "message3")
        self.assertEqual(c.get_time(), datetime.datetime(2015, 6, 11, 12))