How to use the pysoa.server.action.introspection.IntrospectionAction function in pysoa

To help you get started, we’ve selected a few pysoa examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eventbrite / pysoa / tests / unit / server / action / test_introspection.py View on Github external
def test_whole_server_switched(self):
        action = IntrospectionAction(FakeServerThree())

        response = action(EnrichedActionRequest(action='introspect', body={}))

        self.assertEqual([], response.errors)
        self.assertEqual(
            {
                'documentation': None,
                'action_names': [
                    'introspect',
                    'my_switched_action[DEFAULT]',
                    'my_switched_action[switch:5]',
                    'status',
                    'your_switched_action[DEFAULT]',
                    'your_switched_action[switch:4]',
                ],
                'actions': {
github eventbrite / pysoa / tests / unit / server / action / test_introspection.py View on Github external
def test_single_action_switched(self):
        action = IntrospectionAction(FakeServerThree())

        response = action(EnrichedActionRequest(
            action='introspect',
            body={'action_name': 'my_switched_action[DEFAULT]'},
        ))
        self.assertEqual([], response.errors)
        self.assertEqual(
            {
                'action_names': ['my_switched_action[DEFAULT]'],
                'actions': {
                    'my_switched_action[DEFAULT]': {
                        'documentation': 'The real documentation',
                        'request_schema': None,
                        'response_schema': None,
                    },
                },
github eventbrite / pysoa / tests / unit / server / action / test_introspection.py View on Github external
self.assertEqual([], response.errors)
        self.assertEqual(
            {
                'documentation': None,
                'action_names': [
                    'introspect',
                    'my_switched_action[DEFAULT]',
                    'my_switched_action[switch:5]',
                    'status',
                    'your_switched_action[DEFAULT]',
                    'your_switched_action[switch:4]',
                ],
                'actions': {
                    'introspect': {
                        'documentation': IntrospectionAction.description,
                        'request_schema': IntrospectionAction.request_schema.introspect(),
                        'response_schema': IntrospectionAction.response_schema.introspect(),
                    },
                    'my_switched_action[DEFAULT]': {
                        'documentation': 'The real documentation',
                        'request_schema': None,
                        'response_schema': None,
                    },
                    'my_switched_action[switch:5]': {
                        'documentation': 'Test action documentation',
                        'request_schema': FakeActionTwo.request_schema.introspect(),
                        'response_schema': FakeActionTwo.response_schema.introspect(),
                    },
                    'status': {
                        'documentation': BaseStatusAction.description,
                        'request_schema': BaseStatusAction.request_schema.introspect(),
                        'response_schema': BaseStatusAction.response_schema.introspect(),
github eventbrite / pysoa / tests / unit / server / action / test_introspection.py View on Github external
self.assertEqual(
            {
                'documentation': None,
                'action_names': [
                    'introspect',
                    'my_switched_action[DEFAULT]',
                    'my_switched_action[switch:5]',
                    'status',
                    'your_switched_action[DEFAULT]',
                    'your_switched_action[switch:4]',
                ],
                'actions': {
                    'introspect': {
                        'documentation': IntrospectionAction.description,
                        'request_schema': IntrospectionAction.request_schema.introspect(),
                        'response_schema': IntrospectionAction.response_schema.introspect(),
                    },
                    'my_switched_action[DEFAULT]': {
                        'documentation': 'The real documentation',
                        'request_schema': None,
                        'response_schema': None,
                    },
                    'my_switched_action[switch:5]': {
                        'documentation': 'Test action documentation',
                        'request_schema': FakeActionTwo.request_schema.introspect(),
                        'response_schema': FakeActionTwo.response_schema.introspect(),
                    },
                    'status': {
                        'documentation': BaseStatusAction.description,
                        'request_schema': BaseStatusAction.request_schema.introspect(),
                        'response_schema': BaseStatusAction.response_schema.introspect(),
                    },
github eventbrite / pysoa / tests / unit / server / action / test_introspection.py View on Github external
self.assertEqual([], response.errors)
        self.assertEqual(
            {
                'documentation': None,
                'action_names': [
                    'introspect',
                    'my_switched_action[DEFAULT]',
                    'my_switched_action[switch:5]',
                    'status',
                    'your_switched_action[DEFAULT]',
                    'your_switched_action[switch:4]',
                ],
                'actions': {
                    'introspect': {
                        'documentation': IntrospectionAction.description,
                        'request_schema': IntrospectionAction.request_schema.introspect(),
                        'response_schema': IntrospectionAction.response_schema.introspect(),
                    },
                    'my_switched_action[DEFAULT]': {
                        'documentation': 'The real documentation',
                        'request_schema': None,
                        'response_schema': None,
                    },
                    'my_switched_action[switch:5]': {
                        'documentation': 'Test action documentation',
                        'request_schema': FakeActionTwo.request_schema.introspect(),
                        'response_schema': FakeActionTwo.response_schema.introspect(),
                    },
                    'status': {
                        'documentation': BaseStatusAction.description,
                        'request_schema': BaseStatusAction.request_schema.introspect(),
github eventbrite / pysoa / tests / unit / server / action / test_introspection.py View on Github external
def test_single_action_status_default(self):
        action = IntrospectionAction(FakeServerTwo())

        response = action(EnrichedActionRequest(action='introspect', body={'action_name': 'status'}))

        self.assertEqual([], response.errors)
        self.assertEqual(
            {
                'action_names': ['status'],
                'actions': {
                    'status': {
                        'documentation': BaseStatusAction.description,
                        'request_schema': BaseStatusAction.request_schema.introspect(),
                        'response_schema': BaseStatusAction.response_schema.introspect(),
                    },
                },
            },
            response.body,
github eventbrite / pysoa / tests / unit / server / action / test_introspection.py View on Github external
def test_single_action_complex(self):
        action = IntrospectionAction(FakeServerTwo())

        response = action(EnrichedActionRequest(action='introspect', body={'action_name': 'two'}))

        self.assertEqual([], response.errors)
        self.assertEqual(
            {
                'action_names': ['two'],
                'actions': {
                    'two': {
                        'documentation': 'Test action documentation',
                        'request_schema': FakeActionTwo.request_schema.introspect(),
                        'response_schema': FakeActionTwo.response_schema.introspect(),
                    },
                },
            },
            response.body,
github eventbrite / pysoa / tests / unit / server / action / test_introspection.py View on Github external
def test_single_action_simple(self):
        action = IntrospectionAction(FakeServerOne())

        response = action(EnrichedActionRequest(action='introspect', body={'action_name': 'one'}))

        self.assertEqual([], response.errors)
        self.assertEqual(
            {
                'action_names': ['one'],
                'actions': {
                    'one': {
                        'documentation': 'The real documentation',
                        'request_schema': None,
                        'response_schema': None,
                    },
                },
            },
            response.body,
github eventbrite / pysoa / pysoa / server / server.py View on Github external
switches=job_switches,
                context=job_request.context,
                control=job_request.control,
                client=job_request.client,
                run_coroutine=job_request.run_coroutine,
            )
            action_request._server = self

            action_in_class_map = action_request.action in self.action_class_map
            if action_in_class_map or action_request.action in ('status', 'introspect'):
                # Get action to run
                if action_in_class_map:
                    action = self.action_class_map[action_request.action](self.settings)
                elif action_request.action == 'introspect':
                    from pysoa.server.action.introspection import IntrospectionAction
                    action = IntrospectionAction(server=self)
                else:
                    if not self._default_status_action_class:
                        from pysoa.server.action.status import make_default_status_action_class
                        self._default_status_action_class = make_default_status_action_class(self.__class__)
                    # noinspection PyTypeChecker
                    action = self._default_status_action_class(self.settings)

                # Wrap it in middleware
                wrapper = self.make_middleware_stack(
                    [m.action for m in self._middleware],
                    action,
                )
                # Execute the middleware stack
                try:
                    PySOALogContextFilter.set_logging_action_name(action_request.action)
                    action_response = wrapper(action_request)