Ejemplo n.º 1
0
    def delete_detail(self, request):
        """
        Implements the Delete Detail (delete an object)

        maps to DELETE /api/object_name/:id/ in rest semantics
        :param request: rip.Request
        :return: rip.Response
        """
        pipeline = crud_pipeline_factory.delete_detail_pipeline(
            configuration=self.configuration)
        return pipeline(request=request)
Ejemplo n.º 2
0
    def test_delete_detail_pipeline_has_all_steps_in_the_right_order(self, compose_pipeline):
        entity_actions = MagicMock()
        entity_actions.delete_detail = delete_detail = MagicMock()
        entity_actions.read_detail = read_detail = MagicMock()
        authentication = MagicMock()
        authentication.authenticate = MagicMock()
        authorization = MagicMock()
        authorization.authorize_delete_detail = authorize_delete_detail = MagicMock()
        cleaner = MagicMock()
        cleaner.clean_data_for_delete_detail = clean_data_for_delete_detail = MagicMock()
        response_converter = MagicMock()
        post_action_hooks = MagicMock()
        post_action_hooks.delete_detail_hook = delete_detail_hook = MagicMock()
        response_converter.convert_to_simple_response = convert_to_simple_response = MagicMock()

        compose_pipeline.return_value = expected_pipeline = MagicMock()
        configuration = {
            "entity_actions": entity_actions,
            "authentication": authentication,
            "authorization": authorization,
            "data_cleaner": cleaner,
            "response_converter": response_converter,
            "post_action_hooks": post_action_hooks,
        }

        pipeline = crud_pipeline_factory.delete_detail_pipeline(configuration)

        assert_that(pipeline, equal_to(expected_pipeline))
        compose_pipeline.assert_called_once_with(
            name=CrudActions.DELETE_DETAIL,
            pipeline=[
                authentication.authenticate,
                clean_data_for_delete_detail,
                read_detail,
                authorize_delete_detail,
                delete_detail,
                delete_detail_hook,
                convert_to_simple_response,
            ],
        )
Ejemplo n.º 3
0
    def test_delete_detail_pipeline_has_all_steps_in_the_right_order(
            self, compose_pipeline):
        entity_actions = MagicMock()
        entity_actions.delete_detail = delete_detail = MagicMock()
        entity_actions.read_detail = read_detail = MagicMock()
        authentication = MagicMock()
        authentication.authenticate = MagicMock()
        authorization = MagicMock()
        authorization \
            .authorize_delete_detail = authorize_delete_detail = MagicMock()
        cleaner = MagicMock()
        cleaner.clean_data_for_delete_detail = \
            clean_data_for_delete_detail = MagicMock()
        response_converter = MagicMock()
        post_action_hooks = MagicMock()
        post_action_hooks.delete_detail_hook = delete_detail_hook = MagicMock()
        response_converter.convert_to_simple_response = \
            convert_to_simple_response = MagicMock()

        compose_pipeline.return_value = expected_pipeline = MagicMock()
        configuration = {
            'entity_actions': entity_actions,
            'authentication': authentication,
            'authorization': authorization,
            'data_cleaner': cleaner,
            'response_converter': response_converter,
            'post_action_hooks': post_action_hooks
        }

        pipeline = crud_pipeline_factory.delete_detail_pipeline(configuration)

        assert_that(pipeline, equal_to(expected_pipeline))
        compose_pipeline.assert_called_once_with(
            name=CrudActions.DELETE_DETAIL,
            pipeline=[
                authentication.authenticate, clean_data_for_delete_detail,
                read_detail, authorize_delete_detail, delete_detail,
                delete_detail_hook, convert_to_simple_response
            ])