예제 #1
0
def _evaluate_namespace(backend, namespace_list):
    # type: (TSDTypesBackend, typing.List[ApiNamespace]) -> typing.Text

    get_result = _mock_output(backend)
    filename = "types.d.ts"
    backend.split_by_namespace = False
    backend._generate_base_namespace_module(namespace_list=namespace_list,
                                            filename=filename,
                                            extra_args={},
                                            template="""/*TYPES*/""",
                                            exclude_error_types=True)
    return get_result()
예제 #2
0
def _evaluate_namespace(backend, namespace_list):
    # type: (TSDTypesBackend, typing.List[ApiNamespace]) -> typing.Text

    get_result = _mock_output(backend)
    filename = "types.d.ts"
    backend.split_by_namespace = False
    backend._generate_base_namespace_module(namespace_list=namespace_list,
                                            filename=filename,
                                            extra_args={},
                                            template="""/*TYPES*/""",
                                            exclude_error_types=True)
    return get_result()
예제 #3
0
    def test_wrap_response_in_flag(self):
        # type: () -> None
        api, _ = self._get_api()
        backend = JavascriptClientBackend(target_folder_path='output',
                                          args=[
                                              'files', '-c', 'DropboxBase',
                                              '--wrap-response-in',
                                              'DropboxResponse'
                                          ])
        get_result = _mock_output(backend)
        backend.generate(api)
        result = get_result()

        expected = textwrap.dedent('''\
            // Auto-generated by Stone, do not modify.
            var routes = {};

            /**
             * get_metadata
             * @function DropboxBase#filesGetMetadata
             * @returns {Promise.<DropboxResponse<void>, Error.<void>>}
             */
            routes.filesGetMetadata = function () {
              return this.request("files/get_metadata", null);
            };

            /**
             * get_metadata_v2
             * @function DropboxBase#filesGetMetadataV2
             * @returns {Promise.<DropboxResponse<number>, Error.<void>>}
             */
            routes.filesGetMetadataV2 = function () {
              return this.request("files/get_metadata_v2", null);
            };

            /**
             * get_metadata_v3
             * @function DropboxBase#filesGetMetadataV3
             * @arg {number} arg - The request parameters.
             * @returns {Promise.<DropboxResponse<number>, Error.<void>>}
             */
            routes.filesGetMetadataV3 = function (arg) {
              return this.request("files/get_metadata_v3", arg);
            };

            export { routes };
            ''')
        assert result == expected
예제 #4
0
    def test_route_versions(self):
        # type: () -> None
        api, _ = self._get_api()
        backend = JavascriptClientBackend(
            target_folder_path='output',
            args=['files', '-c', 'DropboxBase'])
        get_result = _mock_output(backend)
        backend.generate(api)
        result = get_result()

        expected = textwrap.dedent('''\
            // Auto-generated by Stone, do not modify.
            var routes = {};

            /**
             * get_metadata
             * @function DropboxBase#filesGetMetadata
             * @arg {void} arg - The request parameters.
             * @returns {Promise.<void, Error.<void>>}
             */
            routes.filesGetMetadata = function (arg) {
              return this.request("files/get_metadata", arg);
            };

            /**
             * get_metadata_v2
             * @function DropboxBase#filesGetMetadataV2
             * @arg {void} arg - The request parameters.
             * @returns {Promise.<number, Error.<void>>}
             */
            routes.filesGetMetadataV2 = function (arg) {
              return this.request("files/get_metadata_v2", arg);
            };

            export { routes };
            ''')
        assert result == expected