def test_update_then_save(self):
        ada = TravelArrangementDataAccess("test.ini")
        ada.load()
        a = TravelArrangement()
        a.set_id("id1")
        a.set_name("name 1.1")
        a.set_description("description 1.1")
        self.assertTrue(ada.update(a))
        ada.save()

        with open("test.ini", "rt") as f:
            self.assertEqual(f.readline(), "[id1]\n")
            self.assertEqual(f.readline(), "name = name 1.1\n")
            self.assertEqual(f.readline(), "description = description 1.1\n")


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

            self.assertEqual(f.readline(), "[id2]\n")
            self.assertEqual(f.readline(), "name = name 2\n")
            self.assertEqual(f.readline(), "description = desc 2\n")

            self.assertEqual(f.readline(), "\n")
            
            self.assertEqual(f.readline(), "[id3]\n")
            self.assertEqual(f.readline(), "name = name 3\n")
            self.assertEqual(f.readline(), "description = desc 3\n")

            self.assertEqual(f.readline(), "\n")
            self.assertEqual(f.readline(), "")
    def test_add_save(self):
        ada = TravelArrangementDataAccess("test.ini")
        r = TravelArrangement()
        r.set_id("id3")
        r.set_name("name 3")
        r.set_description("desc 3")

        self.assertTrue(ada.add(r))
        ada.save()

        with open("test.ini", "rt") as f:
            self.assertEqual(f.readline(), "[id3]\n")
            self.assertEqual(f.readline(), "name = name 3\n")
            self.assertEqual(f.readline(), "description = desc 3\n")
    def test_add_then_list(self):
        ada = TravelArrangementDataAccess("test.ini")
        ada.load()
        a = TravelArrangement()
        a.set_id("id4")
        a.set_name("name 4")
        a.set_description("desc 4")
        self.assertTrue(ada.add(a))

        allCmt = ada.list_all()
        self.assertEqual(len(allCmt), 4)
        
        lastCmt = allCmt[3]
        self.assertFalse(lastCmt is a)

        self.assertEqual(lastCmt.get_id(), "id4")
        self.assertEqual(lastCmt.get_name(), "name 4")
        self.assertEqual(lastCmt.get_description(), "desc 4")
 def test_is_complete(self):
     p= TravelArrangement()
     self.assertFalse(p.is_complete())
     p.set_id("1")
     self.assertFalse(p.is_complete())
     p.set_name("1")
     self.assertFalse(p.is_complete())
     p.set_description("1")
     self.assertTrue(p.is_complete())
 def test_description(self):
     p = TravelArrangement()
     p.set_description("description 1")
     self.assertEqual(p.get_description(), "description 1")
     p.set_description("description 2")
     self.assertEqual(p.get_description(), "description 2")
 def test_name(self):
     p = TravelArrangement()
     p.set_name("name 1")
     self.assertEqual(p.get_name(), "name 1")
     p.set_name("name 2")
     self.assertEqual(p.get_name(), "name 2")
 def test_id(self):
     p = TravelArrangement()
     p.set_id("1")
     self.assertEqual(p.get_id(), "1")
     p.set_id("2")
     self.assertEqual(p.get_id(), "2")
    def test_update_then_list(self):
        ada = TravelArrangementDataAccess("test.ini")
        ada.load()
        a = TravelArrangement()
        a.set_id("id1")
        a.set_name("name 1.1")
        a.set_description("desc 1.1")

        self.assertTrue(ada.update(a))
        tlist = ada.list_all()
        
        self.assertEqual(len(tlist), 3)

        a = tlist[0]
        self.assertEqual(a.get_id(), "id1")
        self.assertEqual(a.get_name(), "name 1.1")
        self.assertEqual(a.get_description(), "desc 1.1")

        a = tlist[1]
        self.assertEqual(a.get_id(), "id2")
        self.assertEqual(a.get_name(), "name 2")
        self.assertEqual(a.get_description(), "desc 2")

        a = tlist[2]
        self.assertEqual(a.get_id(), "id3")
        self.assertEqual(a.get_name(), "name 3")
        self.assertEqual(a.get_description(), "desc 3")