def test_update_then_list(self):
        rda = ActivityReservationDataAccess("test.ini")
        rda.load()
        r = ActivityReservation()
        r.set_id("id1")
        r.set_start_time(2015, 1, 1, 1)
        r.set_end_time(2015, 1, 1, 3)
        r.set_activity_id("room0")
        r.set_user_id("reserver0")
        rda.update_reservation(r)
        rlist = rda.list_all_reservations()
        
        self.assertEqual(len(rlist), 3)

        rsv = rlist[0]
        self.assertEqual(rsv.get_id(), "id1")
        self.assertEqual(rsv.get_user_id(), "reserver0")
        self.assertEqual(rsv.get_activity_id(), "room0")
        self.assertEqual(rsv.get_start_time(), datetime.datetime(2015, 1, 1, 1))
        self.assertEqual(rsv.get_end_time(), datetime.datetime(2015, 1, 1, 3))        

        rsv = rlist[1]
        self.assertEqual(rsv.get_id(), "id2")
        self.assertEqual(rsv.get_user_id(), "reserver2")
        self.assertEqual(rsv.get_activity_id(), "room2")
        self.assertEqual(rsv.get_start_time(), datetime.datetime(2015, 6, 10, 12))
        self.assertEqual(rsv.get_end_time(), datetime.datetime(2015, 6, 10, 16))

        rsv = rlist[2]
        self.assertEqual(rsv.get_id(), "id3")
        self.assertEqual(rsv.get_user_id(), "reserver3")
        self.assertEqual(rsv.get_activity_id(), "room3")
        self.assertEqual(rsv.get_start_time(), datetime.datetime(2015, 6, 11, 12))
        self.assertEqual(rsv.get_end_time(), datetime.datetime(2015, 6, 12, 16))
    def test_update_with_conflict_then_save(self):
        rda = ActivityReservationDataAccess("test.ini")
        rda.load()
        r = ActivityReservation()
        r.set_id("id1")
        r.set_start_time(2015, 6, 11, 1)
        r.set_end_time(2015, 6, 12, 3)
        r.set_activity_id("room3")
        r.set_user_id("reserver1")
        self.assertFalse(rda.update_reservation(r))
        r.set_id("id4")
        r.set_start_time(2015, 6, 11, 1)
        r.set_end_time(2015, 6, 12, 3)
        r.set_activity_id("room0")
        r.set_user_id("reserver4")
        self.assertFalse(rda.update_reservation(r))
        r.set_id("id1")
        r.set_start_time(2015, 6, 11, 1)
        r.set_end_time(2015, 6, 12, 3)
        r.set_activity_id("room0")
        r.set_user_id("reserver3")
        self.assertFalse(rda.update_reservation(r))
        rda.save()

        with open("test.ini", "rt") as f:
            self.assertEqual(f.readline(), "[id1]\n")
            self.assertEqual(f.readline(), "start time = 06/10/15 12:00:00\n")
            self.assertEqual(f.readline(), "end time = 06/10/15 16:00:00\n")
            self.assertEqual(f.readline(), "user id = reserver1\n")
            self.assertEqual(f.readline(), "activity id = room1\n")

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

            self.assertEqual(f.readline(), "[id2]\n")
            self.assertEqual(f.readline(), "start time = 06/10/15 12:00:00\n")
            self.assertEqual(f.readline(), "end time = 06/10/15 16:00:00\n")
            self.assertEqual(f.readline(), "user id = reserver2\n")
            self.assertEqual(f.readline(), "activity id = room2\n")

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

            self.assertEqual(f.readline(), "[id3]\n")
            self.assertEqual(f.readline(), "start time = 06/11/15 12:00:00\n")
            self.assertEqual(f.readline(), "end time = 06/12/15 16:00:00\n")
            self.assertEqual(f.readline(), "user id = reserver3\n")
            self.assertEqual(f.readline(), "activity id = room3\n")

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