Пример #1
0
    def test_render_facade__get_bulk_read_field(self):

        self.mocker.patch.object(Command,
                                 'get_bulk_read_field').return_value = 'people'
        command = Command(
            'READ_TASK', {
                'method': 'GET',
                'meta': {
                    'title': 'Read Task',
                    'domain': {
                        'id': 'tasks',
                        'name': 'Tasks Management',
                    }
                },
                'access': {
                    'is_private': True,
                    'access_list': ['LEARNER'],
                },
                'path_conf': {
                    'path': '/tasks/{task_id}',
                    'parameters': [
                        {
                            'name': 'task_id',
                            'type': 'integer',
                        },
                    ]
                },
                'schemas': {
                    'input_query': {
                        'schema': {
                            'hi': 'there'
                        },
                        'uri': ''
                    },
                    'input_body': None,
                    'output': {
                        'schema': {
                            'type': 'object',
                            'required': ['people'],
                            'properties': {
                                'people': {
                                    'type': 'array',
                                },
                            },
                        },
                        'uri': '',
                    },
                },
                'examples': {},
            })

        assert command.render_facade() == normalize_indentation(
            '''
            readTask(taskId: any, params: X.ReadTaskQuery): Observable<X.ReadTaskResponse> {
                return this.tasksDomain.readTask(taskId, params);
            }
        ''', 0)  # noqa
Пример #2
0
    def test_render_facade__post(self):

        command = Command(
            'READ_TASK', {
                'method': 'POST',
                'meta': {
                    'title': 'Create Path',
                    'domain': {
                        'id': 'paths',
                        'name': 'Paths Management',
                    }
                },
                'access': {
                    'is_private': True,
                    'access_list': ['LEARNER'],
                },
                'path_conf': {
                    'path': '/paths/',
                    'parameters': []
                },
                'schemas': {
                    'input_query': None,
                    'input_body': {
                        'schema': {
                            'hi': 'there'
                        },
                        'uri': ''
                    },
                    'output': {
                        'schema': {
                            'hi': 'there'
                        },
                        'uri': ''
                    },
                },
                'examples': {},
            })

        assert command.render_facade() == normalize_indentation(
            '''
            readTask(body: X.ReadTaskBody): Observable<X.ReadTaskResponse> {
                return this.pathsDomain.readTask(body);
            }
        ''', 0)  # noqa