def test_place_system_error(self):
        scheduler = MagicMock()
        scheduler.place.side_effect = ValueError

        handler = SchedulerHandler()
        handler._schedulers["foo"] = scheduler
        response = handler.place(PlaceRequest(Resource(), "foo"))

        assert_that(response.result, is_(PlaceResultCode.SYSTEM_ERROR))
    def test_place_system_error(self):
        scheduler = MagicMock()
        scheduler.place.side_effect = ValueError

        handler = SchedulerHandler()
        handler._schedulers["foo"] = scheduler
        response = handler.place(PlaceRequest(Resource(), "foo"))

        assert_that(response.result, is_(PlaceResultCode.SYSTEM_ERROR))
    def test_place_response(self):
        response = PlaceResponse(PlaceResultCode.OK)

        scheduler = MagicMock()
        scheduler.place.return_value = response

        handler = SchedulerHandler()
        handler._schedulers["foo"] = scheduler
        actual_response = handler.place(PlaceRequest(Resource(), "foo"))

        assert_that(actual_response, is_(same_instance(response)))
    def test_place_response(self):
        response = PlaceResponse(PlaceResultCode.OK)

        scheduler = MagicMock()
        scheduler.place.return_value = response

        handler = SchedulerHandler()
        handler._schedulers["foo"] = scheduler
        actual_response = handler.place(PlaceRequest(Resource(), "foo"))

        assert_that(actual_response, is_(same_instance(response)))
    def test_place_missing_scheduler(self):
        handler = SchedulerHandler()
        response = handler.place(PlaceRequest(Resource()))

        assert_that(response.result, is_(PlaceResultCode.INVALID_SCHEDULER))
    def test_place_missing_scheduler(self):
        handler = SchedulerHandler()
        response = handler.place(PlaceRequest(Resource()))

        assert_that(response.result, is_(PlaceResultCode.INVALID_SCHEDULER))