def setUp(self):

        locator_mock = None

        self.cfg_manager = ConfigurationManager.ConfigurationManager()
        self.cfg_manager.append_module(configuration_module)

        self.coordinator = WrappedCoordinator(locator_mock, self.cfg_manager, ConfirmerClass = ConfirmerMock)
        self.coordinator._clean()

        self.coordinator.add_experiment_instance_id("lab1:inst@machine", ExperimentInstanceId('inst1', 'exp1','cat1'), Resource("res_type", "res_inst1"))
        self.coordinator.add_experiment_instance_id("lab2:inst@machine", ExperimentInstanceId('inst2', 'exp2','cat1'), Resource("res_type", "res_inst2"))

        self.reservations_manager = self.coordinator.reservations_manager
class ReservationsManagerTestCase(unittest.TestCase):
    def setUp(self):

        locator_mock = None

        self.cfg_manager = ConfigurationManager.ConfigurationManager()
        self.cfg_manager.append_module(configuration_module)

        self.coordinator = WrappedCoordinator(locator_mock, self.cfg_manager, ConfirmerClass = ConfirmerMock)
        self.coordinator._clean()

        self.coordinator.add_experiment_instance_id("lab1:inst@machine", ExperimentInstanceId('inst1', 'exp1','cat1'), Resource("res_type", "res_inst1"))
        self.coordinator.add_experiment_instance_id("lab2:inst@machine", ExperimentInstanceId('inst2', 'exp2','cat1'), Resource("res_type", "res_inst2"))

        self.reservations_manager = self.coordinator.reservations_manager

    def tearDown(self):
        self.coordinator.stop()
        self.coordinator._clean()

    def test_list_sessions_not_existing(self):
        exp_id = ExperimentId("exp.that.doesnt.exist","cat1")

        self.assertRaises(
            CoordExc.ExperimentNotFoundError,
            self.reservations_manager.list_sessions,
            exp_id
        )

    def test_list_sessions(self):
        exp_id1 = ExperimentId("exp1","cat1")
        exp_id2 = ExperimentId("exp2","cat1")

        sessions = self.reservations_manager.list_sessions(exp_id1)
        self.assertEquals(0, len(sessions))

        reservation1 = self.reservations_manager.create(exp_id1, "{}", REQUEST_INFO)
        reservation2 = self.reservations_manager.create(exp_id1, "{}", REQUEST_INFO)

        self.reservations_manager.create(exp_id2, "{}", REQUEST_INFO)

        sessions = self.reservations_manager.list_sessions(exp_id1)
        self.assertEquals(2, len(sessions))
        self.assertTrue(reservation1 in sessions)
        self.assertTrue(reservation2 in sessions)