diff --git a/ibmcloudant/cloudant_v1.py b/ibmcloudant/cloudant_v1.py index 2e2f6f7c..6707fd6e 100644 --- a/ibmcloudant/cloudant_v1.py +++ b/ibmcloudant/cloudant_v1.py @@ -291,8 +291,7 @@ def get_all_dbs(self, def post_dbs_info(self, - *, - keys: List[str] = None, + keys: List[str], **kwargs ) -> DetailedResponse: """ @@ -303,12 +302,14 @@ def post_dbs_info(self, list that contains an information object for each database specified in the request. - :param List[str] keys: (optional) A list of database names. + :param List[str] keys: A list of database names. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `List[DbsInfoResult]` result """ + if keys is None: + raise ValueError('keys must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', @@ -896,8 +897,8 @@ def head_document(self, def post_document(self, db: str, + document: Union['Document', BinaryIO], *, - document: Union['Document', BinaryIO] = None, content_type: str = None, batch: str = None, **kwargs @@ -915,8 +916,7 @@ def post_document(self, documents respectively. :param str db: Path parameter to specify the database name. - :param Document document: (optional) HTTP request body for Document - operations. + :param Document document: HTTP request body for Document operations. :param str content_type: (optional) The type of the input. :param str batch: (optional) Query parameter to specify whether to store in batch mode. The server will respond with a HTTP 202 Accepted response code @@ -928,7 +928,9 @@ def post_document(self, if db is None: raise ValueError('db must be provided') - if document is not None and isinstance(document, Document): + if document is None: + raise ValueError('document must be provided') + if isinstance(document, Document): document = convert_model(document) content_type = content_type or 'application/json' headers = { @@ -943,7 +945,7 @@ def post_document(self, 'batch': batch } - if document is not None and isinstance(document, dict): + if isinstance(document, dict): data = json.dumps(document) if content_type is None: headers['Content-Type'] = 'application/json' @@ -1176,8 +1178,7 @@ def post_all_docs_as_stream(self, def post_all_docs_queries(self, db: str, - *, - queries: List['AllDocsQuery'] = None, + queries: List['AllDocsQuery'], **kwargs ) -> DetailedResponse: """ @@ -1190,10 +1191,10 @@ def post_all_docs_queries(self, /{db}/_all_docs` requests. :param str db: Path parameter to specify the database name. - :param List[AllDocsQuery] queries: (optional) An array of query objects - with fields for the parameters of each individual view query to be - executed. The field names and their meaning are the same as the query - parameters of a regular `/_all_docs` request. + :param List[AllDocsQuery] queries: An array of query objects with fields + for the parameters of each individual view query to be executed. The field + names and their meaning are the same as the query parameters of a regular + `/_all_docs` request. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `AllDocsQueriesResult` object @@ -1201,8 +1202,9 @@ def post_all_docs_queries(self, if db is None: raise ValueError('db must be provided') - if queries is not None: - queries = [convert_model(x) for x in queries] + if queries is None: + raise ValueError('queries must be provided') + queries = [convert_model(x) for x in queries] headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', @@ -1235,8 +1237,7 @@ def post_all_docs_queries(self, def post_all_docs_queries_as_stream(self, db: str, - *, - queries: List['AllDocsQuery'] = None, + queries: List['AllDocsQuery'], **kwargs ) -> DetailedResponse: """ @@ -1249,10 +1250,10 @@ def post_all_docs_queries_as_stream(self, /{db}/_all_docs` requests. :param str db: Path parameter to specify the database name. - :param List[AllDocsQuery] queries: (optional) An array of query objects - with fields for the parameters of each individual view query to be - executed. The field names and their meaning are the same as the query - parameters of a regular `/_all_docs` request. + :param List[AllDocsQuery] queries: An array of query objects with fields + for the parameters of each individual view query to be executed. The field + names and their meaning are the same as the query parameters of a regular + `/_all_docs` request. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `BinaryIO` result @@ -1260,8 +1261,9 @@ def post_all_docs_queries_as_stream(self, if db is None: raise ValueError('db must be provided') - if queries is not None: - queries = [convert_model(x) for x in queries] + if queries is None: + raise ValueError('queries must be provided') + queries = [convert_model(x) for x in queries] headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', @@ -1294,8 +1296,7 @@ def post_all_docs_queries_as_stream(self, def post_bulk_docs(self, db: str, - *, - bulk_docs: Union['BulkDocs', BinaryIO] = None, + bulk_docs: Union['BulkDocs', BinaryIO], **kwargs ) -> DetailedResponse: """ @@ -1307,7 +1308,7 @@ def post_bulk_docs(self, information. :param str db: Path parameter to specify the database name. - :param BulkDocs bulk_docs: (optional) HTTP request body for postBulkDocs. + :param BulkDocs bulk_docs: HTTP request body for postBulkDocs. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `List[DocumentResult]` result @@ -1315,7 +1316,9 @@ def post_bulk_docs(self, if db is None: raise ValueError('db must be provided') - if bulk_docs is not None and isinstance(bulk_docs, BulkDocs): + if bulk_docs is None: + raise ValueError('bulk_docs must be provided') + if isinstance(bulk_docs, BulkDocs): bulk_docs = convert_model(bulk_docs) headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, @@ -1348,8 +1351,8 @@ def post_bulk_docs(self, def post_bulk_get(self, db: str, + docs: List['BulkGetQueryDocument'], *, - docs: List['BulkGetQueryDocument'] = None, attachments: bool = None, att_encoding_info: bool = None, latest: bool = None, @@ -1363,8 +1366,8 @@ def post_bulk_get(self, replicators do. :param str db: Path parameter to specify the database name. - :param List[BulkGetQueryDocument] docs: (optional) List of document items - to get in bulk. + :param List[BulkGetQueryDocument] docs: List of document items to get in + bulk. :param bool attachments: (optional) Query parameter to specify whether to include attachments bodies in a response. :param bool att_encoding_info: (optional) Query parameter to specify @@ -1381,8 +1384,9 @@ def post_bulk_get(self, if db is None: raise ValueError('db must be provided') - if docs is not None: - docs = [convert_model(x) for x in docs] + if docs is None: + raise ValueError('docs must be provided') + docs = [convert_model(x) for x in docs] headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', @@ -1423,8 +1427,8 @@ def post_bulk_get(self, def post_bulk_get_as_mixed(self, db: str, + docs: List['BulkGetQueryDocument'], *, - docs: List['BulkGetQueryDocument'] = None, attachments: bool = None, att_encoding_info: bool = None, latest: bool = None, @@ -1438,8 +1442,8 @@ def post_bulk_get_as_mixed(self, replicators do. :param str db: Path parameter to specify the database name. - :param List[BulkGetQueryDocument] docs: (optional) List of document items - to get in bulk. + :param List[BulkGetQueryDocument] docs: List of document items to get in + bulk. :param bool attachments: (optional) Query parameter to specify whether to include attachments bodies in a response. :param bool att_encoding_info: (optional) Query parameter to specify @@ -1456,8 +1460,9 @@ def post_bulk_get_as_mixed(self, if db is None: raise ValueError('db must be provided') - if docs is not None: - docs = [convert_model(x) for x in docs] + if docs is None: + raise ValueError('docs must be provided') + docs = [convert_model(x) for x in docs] headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', @@ -1498,8 +1503,8 @@ def post_bulk_get_as_mixed(self, def post_bulk_get_as_related(self, db: str, + docs: List['BulkGetQueryDocument'], *, - docs: List['BulkGetQueryDocument'] = None, attachments: bool = None, att_encoding_info: bool = None, latest: bool = None, @@ -1513,8 +1518,8 @@ def post_bulk_get_as_related(self, replicators do. :param str db: Path parameter to specify the database name. - :param List[BulkGetQueryDocument] docs: (optional) List of document items - to get in bulk. + :param List[BulkGetQueryDocument] docs: List of document items to get in + bulk. :param bool attachments: (optional) Query parameter to specify whether to include attachments bodies in a response. :param bool att_encoding_info: (optional) Query parameter to specify @@ -1531,8 +1536,9 @@ def post_bulk_get_as_related(self, if db is None: raise ValueError('db must be provided') - if docs is not None: - docs = [convert_model(x) for x in docs] + if docs is None: + raise ValueError('docs must be provided') + docs = [convert_model(x) for x in docs] headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', @@ -1573,8 +1579,8 @@ def post_bulk_get_as_related(self, def post_bulk_get_as_stream(self, db: str, + docs: List['BulkGetQueryDocument'], *, - docs: List['BulkGetQueryDocument'] = None, attachments: bool = None, att_encoding_info: bool = None, latest: bool = None, @@ -1588,8 +1594,8 @@ def post_bulk_get_as_stream(self, replicators do. :param str db: Path parameter to specify the database name. - :param List[BulkGetQueryDocument] docs: (optional) List of document items - to get in bulk. + :param List[BulkGetQueryDocument] docs: List of document items to get in + bulk. :param bool attachments: (optional) Query parameter to specify whether to include attachments bodies in a response. :param bool att_encoding_info: (optional) Query parameter to specify @@ -1606,8 +1612,9 @@ def post_bulk_get_as_stream(self, if db is None: raise ValueError('db must be provided') - if docs is not None: - docs = [convert_model(x) for x in docs] + if docs is None: + raise ValueError('docs must be provided') + docs = [convert_model(x) for x in docs] headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', @@ -2146,8 +2153,8 @@ def get_document_as_stream(self, def put_document(self, db: str, doc_id: str, + document: Union['Document', BinaryIO], *, - document: Union['Document', BinaryIO] = None, content_type: str = None, if_match: str = None, batch: str = None, @@ -2164,8 +2171,7 @@ def put_document(self, :param str db: Path parameter to specify the database name. :param str doc_id: Path parameter to specify the document ID. - :param Document document: (optional) HTTP request body for Document - operations. + :param Document document: HTTP request body for Document operations. :param str content_type: (optional) The type of the input. :param str if_match: (optional) Header parameter to specify the document revision. Alternative to rev query parameter. @@ -2187,7 +2193,9 @@ def put_document(self, raise ValueError('db must be provided') if doc_id is None: raise ValueError('doc_id must be provided') - if document is not None and isinstance(document, Document): + if document is None: + raise ValueError('document must be provided') + if isinstance(document, Document): document = convert_model(document) content_type = content_type or 'application/json' headers = { @@ -2205,7 +2213,7 @@ def put_document(self, 'rev': rev } - if document is not None and isinstance(document, dict): + if isinstance(document, dict): data = json.dumps(document) if content_type is None: headers['Content-Type'] = 'application/json' @@ -2470,8 +2478,8 @@ def get_design_document(self, def put_design_document(self, db: str, ddoc: str, + design_document: 'DesignDocument', *, - design_document: 'DesignDocument' = None, if_match: str = None, batch: str = None, new_edits: bool = None, @@ -2488,8 +2496,8 @@ def put_design_document(self, :param str ddoc: Path parameter to specify the design document name. The design document name is the design document ID excluding the `_design/` prefix. - :param DesignDocument design_document: (optional) HTTP request body for - DesignDocument operations. + :param DesignDocument design_document: HTTP request body for DesignDocument + operations. :param str if_match: (optional) Header parameter to specify the document revision. Alternative to rev query parameter. :param str batch: (optional) Query parameter to specify whether to store in @@ -2510,7 +2518,9 @@ def put_design_document(self, raise ValueError('db must be provided') if ddoc is None: raise ValueError('ddoc must be provided') - if design_document is not None and isinstance(design_document, DesignDocument): + if design_document is None: + raise ValueError('design_document must be provided') + if isinstance(design_document, DesignDocument): design_document = convert_model(design_document) headers = { 'If-Match': if_match @@ -2597,7 +2607,6 @@ def get_design_document_information(self, def post_design_docs(self, db: str, *, - accept: str = None, att_encoding_info: bool = None, attachments: bool = None, conflicts: bool = None, @@ -2611,6 +2620,7 @@ def post_design_docs(self, key: str = None, keys: List[str] = None, startkey: str = None, + accept: str = None, **kwargs ) -> DetailedResponse: """ @@ -2624,8 +2634,6 @@ def post_design_docs(self, included in the response. :param str db: Path parameter to specify the database name. - :param str accept: (optional) The type of the response: application/json or - application/octet-stream. :param bool att_encoding_info: (optional) Parameter to specify whether to include the encoding information in attachment stubs if the particular attachment is compressed. @@ -2651,6 +2659,8 @@ def post_design_docs(self, :param str key: (optional) Schema for a document ID. :param List[str] keys: (optional) Schema for a list of document IDs. :param str startkey: (optional) Schema for a document ID. + :param str accept: (optional) The type of the response: application/json or + application/octet-stream. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `AllDocsResult` object @@ -2703,9 +2713,9 @@ def post_design_docs(self, def post_design_docs_queries(self, db: str, + queries: List['AllDocsQuery'], *, accept: str = None, - queries: List['AllDocsQuery'] = None, **kwargs ) -> DetailedResponse: """ @@ -2716,12 +2726,12 @@ def post_design_docs_queries(self, place of multiple POST `/{db}/_design_docs` requests. :param str db: Path parameter to specify the database name. + :param List[AllDocsQuery] queries: An array of query objects with fields + for the parameters of each individual view query to be executed. The field + names and their meaning are the same as the query parameters of a regular + `/_all_docs` request. :param str accept: (optional) The type of the response: application/json or application/octet-stream. - :param List[AllDocsQuery] queries: (optional) An array of query objects - with fields for the parameters of each individual view query to be - executed. The field names and their meaning are the same as the query - parameters of a regular `/_all_docs` request. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `AllDocsQueriesResult` object @@ -2729,8 +2739,9 @@ def post_design_docs_queries(self, if db is None: raise ValueError('db must be provided') - if queries is not None: - queries = [convert_model(x) for x in queries] + if queries is None: + raise ValueError('queries must be provided') + queries = [convert_model(x) for x in queries] headers = { 'Accept': accept } @@ -3060,8 +3071,7 @@ def post_view_queries(self, db: str, ddoc: str, view: str, - *, - queries: List['ViewQuery'] = None, + queries: List['ViewQuery'], **kwargs ) -> DetailedResponse: """ @@ -3076,10 +3086,10 @@ def post_view_queries(self, prefix. :param str view: Path parameter to specify the map reduce view function name. - :param List[ViewQuery] queries: (optional) An array of query objects with - fields for the parameters of each individual view query to be executed. The - field names and their meaning are the same as the query parameters of a - regular view request. + :param List[ViewQuery] queries: An array of query objects with fields for + the parameters of each individual view query to be executed. The field + names and their meaning are the same as the query parameters of a regular + view request. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `ViewQueriesResult` object @@ -3091,8 +3101,9 @@ def post_view_queries(self, raise ValueError('ddoc must be provided') if view is None: raise ValueError('view must be provided') - if queries is not None: - queries = [convert_model(x) for x in queries] + if queries is None: + raise ValueError('queries must be provided') + queries = [convert_model(x) for x in queries] headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', @@ -3127,8 +3138,7 @@ def post_view_queries_as_stream(self, db: str, ddoc: str, view: str, - *, - queries: List['ViewQuery'] = None, + queries: List['ViewQuery'], **kwargs ) -> DetailedResponse: """ @@ -3143,10 +3153,10 @@ def post_view_queries_as_stream(self, prefix. :param str view: Path parameter to specify the map reduce view function name. - :param List[ViewQuery] queries: (optional) An array of query objects with - fields for the parameters of each individual view query to be executed. The - field names and their meaning are the same as the query parameters of a - regular view request. + :param List[ViewQuery] queries: An array of query objects with fields for + the parameters of each individual view query to be executed. The field + names and their meaning are the same as the query parameters of a regular + view request. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `BinaryIO` result @@ -3158,8 +3168,9 @@ def post_view_queries_as_stream(self, raise ValueError('ddoc must be provided') if view is None: raise ValueError('view must be provided') - if queries is not None: - queries = [convert_model(x) for x in queries] + if queries is None: + raise ValueError('queries must be provided') + queries = [convert_model(x) for x in queries] headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', @@ -3460,8 +3471,8 @@ def post_partition_search(self, partition_key: str, ddoc: str, index: str, + query: str, *, - query: str = None, bookmark: str = None, highlight_fields: List[str] = None, highlight_number: int = None, @@ -3490,7 +3501,7 @@ def post_partition_search(self, design document name is the design document ID excluding the `_design/` prefix. :param str index: Path parameter to specify the index name. - :param str query: (optional) The Lucene query to execute. + :param str query: The Lucene query to execute. :param str bookmark: (optional) Opaque bookmark token used when paginating results. :param List[str] highlight_fields: (optional) Specifies which fields to @@ -3538,6 +3549,8 @@ def post_partition_search(self, raise ValueError('ddoc must be provided') if index is None: raise ValueError('index must be provided') + if query is None: + raise ValueError('query must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', @@ -3584,8 +3597,8 @@ def post_partition_search_as_stream(self, partition_key: str, ddoc: str, index: str, + query: str, *, - query: str = None, bookmark: str = None, highlight_fields: List[str] = None, highlight_number: int = None, @@ -3614,7 +3627,7 @@ def post_partition_search_as_stream(self, design document name is the design document ID excluding the `_design/` prefix. :param str index: Path parameter to specify the index name. - :param str query: (optional) The Lucene query to execute. + :param str query: The Lucene query to execute. :param str bookmark: (optional) Opaque bookmark token used when paginating results. :param List[str] highlight_fields: (optional) Specifies which fields to @@ -3662,6 +3675,8 @@ def post_partition_search_as_stream(self, raise ValueError('ddoc must be provided') if index is None: raise ValueError('index must be provided') + if query is None: + raise ValueError('query must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', @@ -4004,8 +4019,8 @@ def post_partition_view_as_stream(self, def post_partition_find(self, db: str, partition_key: str, + selector: dict, *, - selector: dict = None, bookmark: str = None, conflicts: bool = None, execution_stats: bool = None, @@ -4028,9 +4043,9 @@ def post_partition_find(self, :param str db: Path parameter to specify the database name. :param str partition_key: Path parameter to specify the database partition key. - :param dict selector: (optional) JSON object describing criteria used to - select documents. The selector specifies fields in the document, and - provides an expression to evaluate with the field content or other data. + :param dict selector: JSON object describing criteria used to select + documents. The selector specifies fields in the document, and provides an + expression to evaluate with the field content or other data. The selector object must: * Be structured as valid JSON. * Contain a valid query expression. @@ -4086,6 +4101,8 @@ def post_partition_find(self, raise ValueError('db must be provided') if partition_key is None: raise ValueError('partition_key must be provided') + if selector is None: + raise ValueError('selector must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', @@ -4129,8 +4146,8 @@ def post_partition_find(self, def post_partition_find_as_stream(self, db: str, partition_key: str, + selector: dict, *, - selector: dict = None, bookmark: str = None, conflicts: bool = None, execution_stats: bool = None, @@ -4153,9 +4170,9 @@ def post_partition_find_as_stream(self, :param str db: Path parameter to specify the database name. :param str partition_key: Path parameter to specify the database partition key. - :param dict selector: (optional) JSON object describing criteria used to - select documents. The selector specifies fields in the document, and - provides an expression to evaluate with the field content or other data. + :param dict selector: JSON object describing criteria used to select + documents. The selector specifies fields in the document, and provides an + expression to evaluate with the field content or other data. The selector object must: * Be structured as valid JSON. * Contain a valid query expression. @@ -4211,6 +4228,8 @@ def post_partition_find_as_stream(self, raise ValueError('db must be provided') if partition_key is None: raise ValueError('partition_key must be provided') + if selector is None: + raise ValueError('selector must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', @@ -4257,8 +4276,8 @@ def post_partition_find_as_stream(self, def post_explain(self, db: str, + selector: dict, *, - selector: dict = None, bookmark: str = None, conflicts: bool = None, execution_stats: bool = None, @@ -4279,9 +4298,9 @@ def post_explain(self, [`_find` endpoint](#query-an-index-by-using-selector-syntax. :param str db: Path parameter to specify the database name. - :param dict selector: (optional) JSON object describing criteria used to - select documents. The selector specifies fields in the document, and - provides an expression to evaluate with the field content or other data. + :param dict selector: JSON object describing criteria used to select + documents. The selector specifies fields in the document, and provides an + expression to evaluate with the field content or other data. The selector object must: * Be structured as valid JSON. * Contain a valid query expression. @@ -4341,6 +4360,8 @@ def post_explain(self, if db is None: raise ValueError('db must be provided') + if selector is None: + raise ValueError('selector must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', @@ -4384,8 +4405,8 @@ def post_explain(self, def post_find(self, db: str, + selector: dict, *, - selector: dict = None, bookmark: str = None, conflicts: bool = None, execution_stats: bool = None, @@ -4407,9 +4428,9 @@ def post_find(self, endpoint. :param str db: Path parameter to specify the database name. - :param dict selector: (optional) JSON object describing criteria used to - select documents. The selector specifies fields in the document, and - provides an expression to evaluate with the field content or other data. + :param dict selector: JSON object describing criteria used to select + documents. The selector specifies fields in the document, and provides an + expression to evaluate with the field content or other data. The selector object must: * Be structured as valid JSON. * Contain a valid query expression. @@ -4469,6 +4490,8 @@ def post_find(self, if db is None: raise ValueError('db must be provided') + if selector is None: + raise ValueError('selector must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', @@ -4512,8 +4535,8 @@ def post_find(self, def post_find_as_stream(self, db: str, + selector: dict, *, - selector: dict = None, bookmark: str = None, conflicts: bool = None, execution_stats: bool = None, @@ -4535,9 +4558,9 @@ def post_find_as_stream(self, endpoint. :param str db: Path parameter to specify the database name. - :param dict selector: (optional) JSON object describing criteria used to - select documents. The selector specifies fields in the document, and - provides an expression to evaluate with the field content or other data. + :param dict selector: JSON object describing criteria used to select + documents. The selector specifies fields in the document, and provides an + expression to evaluate with the field content or other data. The selector object must: * Be structured as valid JSON. * Contain a valid query expression. @@ -4597,6 +4620,8 @@ def post_find_as_stream(self, if db is None: raise ValueError('db must be provided') + if selector is None: + raise ValueError('selector must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', @@ -4682,10 +4707,10 @@ def get_indexes_information(self, def post_index(self, db: str, + index: 'IndexDefinition', *, ddoc: str = None, def_: 'IndexDefinition' = None, - index: 'IndexDefinition' = None, name: str = None, partial_filter_selector: dict = None, partitioned: bool = None, @@ -4698,6 +4723,12 @@ def post_index(self, Create a new index on a database. :param str db: Path parameter to specify the database name. + :param IndexDefinition index: Schema for a `json` or `text` query index + definition. Indexes of type `text` have additional configuration properties + that do not apply to `json` indexes, these are: + * `default_analyzer` - the default text analyzer to use * `default_field` - + whether to index the text in all document fields and what analyzer to use + for that purpose. :param str ddoc: (optional) Name of the design document in which the index will be created. :param IndexDefinition def_: (optional) Schema for a `json` or `text` query @@ -4706,12 +4737,6 @@ def post_index(self, * `default_analyzer` - the default text analyzer to use * `default_field` - whether to index the text in all document fields and what analyzer to use for that purpose. - :param IndexDefinition index: (optional) Schema for a `json` or `text` - query index definition. Indexes of type `text` have additional - configuration properties that do not apply to `json` indexes, these are: - * `default_analyzer` - the default text analyzer to use * `default_field` - - whether to index the text in all document fields and what analyzer to use - for that purpose. :param str name: (optional) name. :param dict partial_filter_selector: (optional) JSON object describing criteria used to select documents. The selector specifies fields in the @@ -4751,10 +4776,11 @@ def post_index(self, if db is None: raise ValueError('db must be provided') + if index is None: + raise ValueError('index must be provided') + index = convert_model(index) if def_ is not None: def_ = convert_model(def_) - if index is not None: - index = convert_model(index) headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', @@ -4762,9 +4788,9 @@ def post_index(self, headers.update(sdk_headers) data = { + 'index': index, 'ddoc': ddoc, 'def': def_, - 'index': index, 'name': name, 'partial_filter_selector': partial_filter_selector, 'partitioned': partitioned, @@ -4847,9 +4873,8 @@ def delete_index(self, def post_search_analyze(self, - *, - analyzer: str = None, - text: str = None, + analyzer: str, + text: str, **kwargs ) -> DetailedResponse: """ @@ -4858,13 +4883,17 @@ def post_search_analyze(self, Returns the results of analyzer tokenization of the provided sample text. This endpoint can be used for testing analyzer tokenization. - :param str analyzer: (optional) analyzer. - :param str text: (optional) text. + :param str analyzer: analyzer. + :param str text: text. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `SearchAnalyzeResult` object """ + if analyzer is None: + raise ValueError('analyzer must be provided') + if text is None: + raise ValueError('text must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', @@ -4897,8 +4926,8 @@ def post_search(self, db: str, ddoc: str, index: str, + query: str, *, - query: str = None, bookmark: str = None, highlight_fields: List[str] = None, highlight_number: int = None, @@ -4934,7 +4963,7 @@ def post_search(self, design document name is the design document ID excluding the `_design/` prefix. :param str index: Path parameter to specify the index name. - :param str query: (optional) The Lucene query to execute. + :param str query: The Lucene query to execute. :param str bookmark: (optional) Opaque bookmark token used when paginating results. :param List[str] highlight_fields: (optional) Specifies which fields to @@ -5009,6 +5038,8 @@ def post_search(self, raise ValueError('ddoc must be provided') if index is None: raise ValueError('index must be provided') + if query is None: + raise ValueError('query must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', @@ -5060,8 +5091,8 @@ def post_search_as_stream(self, db: str, ddoc: str, index: str, + query: str, *, - query: str = None, bookmark: str = None, highlight_fields: List[str] = None, highlight_number: int = None, @@ -5097,7 +5128,7 @@ def post_search_as_stream(self, design document name is the design document ID excluding the `_design/` prefix. :param str index: Path parameter to specify the index name. - :param str query: (optional) The Lucene query to execute. + :param str query: The Lucene query to execute. :param str bookmark: (optional) Opaque bookmark token used when paginating results. :param List[str] highlight_fields: (optional) Specifies which fields to @@ -5172,6 +5203,8 @@ def post_search_as_stream(self, raise ValueError('ddoc must be provided') if index is None: raise ValueError('index must be provided') + if query is None: + raise ValueError('query must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', @@ -5779,8 +5812,7 @@ def head_scheduler_job(self, def post_replicate(self, - *, - replication_document: 'ReplicationDocument' = None, + replication_document: 'ReplicationDocument', **kwargs ) -> DetailedResponse: """ @@ -5788,14 +5820,16 @@ def post_replicate(self, Requests, configures, or stops a replicate operation. - :param ReplicationDocument replication_document: (optional) HTTP request - body for replication operations. + :param ReplicationDocument replication_document: HTTP request body for + replication operations. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `ReplicationResult` object """ - if replication_document is not None and isinstance(replication_document, ReplicationDocument): + if replication_document is None: + raise ValueError('replication_document must be provided') + if isinstance(replication_document, ReplicationDocument): replication_document = convert_model(replication_document) headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, @@ -5984,8 +6018,8 @@ def get_replication_document(self, def put_replication_document(self, doc_id: str, + replication_document: 'ReplicationDocument', *, - replication_document: 'ReplicationDocument' = None, if_match: str = None, batch: str = None, new_edits: bool = None, @@ -5999,8 +6033,8 @@ def put_replication_document(self, replication or to edit an existing replication. :param str doc_id: Path parameter to specify the document ID. - :param ReplicationDocument replication_document: (optional) HTTP request - body for replication operations. + :param ReplicationDocument replication_document: HTTP request body for + replication operations. :param str if_match: (optional) Header parameter to specify the document revision. Alternative to rev query parameter. :param str batch: (optional) Query parameter to specify whether to store in @@ -6019,7 +6053,9 @@ def put_replication_document(self, if doc_id is None: raise ValueError('doc_id must be provided') - if replication_document is not None and isinstance(replication_document, ReplicationDocument): + if replication_document is None: + raise ValueError('replication_document must be provided') + if isinstance(replication_document, ReplicationDocument): replication_document = convert_model(replication_document) headers = { 'If-Match': if_match @@ -6272,115 +6308,6 @@ def get_session_information(self, response = self.send(request) return response - - def delete_iam_session(self, - **kwargs - ) -> DetailedResponse: - """ - Delete an IAM cookie session. - - Returns a response that instructs the HTTP client to clear the cookie. The session - cookies are stateless and cannot be invalidated; hence, this operation is optional - and does not invalidate the cookie on the server. - - :param dict headers: A `dict` containing the request headers - :return: A `DetailedResponse` containing the result, headers and HTTP status code. - :rtype: DetailedResponse with `dict` result representing a `Ok` object - """ - - headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='delete_iam_session') - headers.update(sdk_headers) - - if 'headers' in kwargs: - headers.update(kwargs.get('headers')) - headers['Accept'] = 'application/json' - - url = '/_iam_session' - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) - - response = self.send(request) - return response - - - def get_iam_session_information(self, - **kwargs - ) -> DetailedResponse: - """ - Retrieve current IAM cookie session information. - - Retrieves information about an IAM cookie session. - - :param dict headers: A `dict` containing the request headers - :return: A `DetailedResponse` containing the result, headers and HTTP status code. - :rtype: DetailedResponse with `dict` result representing a `IamSessionInformation` object - """ - - headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_iam_session_information') - headers.update(sdk_headers) - - if 'headers' in kwargs: - headers.update(kwargs.get('headers')) - headers['Accept'] = 'application/json' - - url = '/_iam_session' - request = self.prepare_request(method='GET', - url=url, - headers=headers) - - response = self.send(request) - return response - - - def post_iam_session(self, - *, - access_token: str = None, - **kwargs - ) -> DetailedResponse: - """ - Create a session cookie by using an IAM token. - - Log in by exchanging an IAM token for an IBM Cloudant cookie. - - :param str access_token: (optional) Token obtained from the IAM service. - :param dict headers: A `dict` containing the request headers - :return: A `DetailedResponse` containing the result, headers and HTTP status code. - :rtype: DetailedResponse with `dict` result representing a `Ok` object - """ - - headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='post_iam_session') - headers.update(sdk_headers) - - data = { - 'access_token': access_token - } - data = {k: v for (k, v) in data.items() if v is not None} - data = json.dumps(data) - headers['content-type'] = 'application/json' - - if 'headers' in kwargs: - headers.update(kwargs.get('headers')) - headers['Accept'] = 'application/json' - - url = '/_iam_session' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) - - response = self.send(request) - return response - ######################### # Authorization ######################### @@ -6537,8 +6464,8 @@ def post_api_keys(self, def put_cloudant_security_configuration(self, db: str, + cloudant: dict, *, - cloudant: dict = None, admins: 'SecurityObject' = None, members: 'SecurityObject' = None, couchdb_auth_only: bool = None, @@ -6552,8 +6479,8 @@ def put_cloudant_security_configuration(self, access to the database. :param str db: Path parameter to specify the database name. - :param dict cloudant: (optional) Database permissions for Cloudant users - and/or API keys. + :param dict cloudant: Database permissions for Cloudant users and/or API + keys. :param SecurityObject admins: (optional) Schema for names and roles to map to a database permission. :param SecurityObject members: (optional) Schema for names and roles to map @@ -6567,6 +6494,8 @@ def put_cloudant_security_configuration(self, if db is None: raise ValueError('db must be provided') + if cloudant is None: + raise ValueError('cloudant must be provided') if admins is not None: admins = convert_model(admins) if members is not None: @@ -6643,8 +6572,8 @@ def get_cors_information(self, def put_cors_configuration(self, + origins: List[str], *, - origins: List[str] = None, allow_credentials: bool = None, enable_cors: bool = None, **kwargs @@ -6655,11 +6584,10 @@ def put_cors_configuration(self, Sets the CORS configuration. The configuration applies to all databases and all account level endpoints in your account. - :param List[str] origins: (optional) An array of strings that contain - allowed origin domains. You have to specify the full URL including the - protocol. It is recommended that only the HTTPS protocol is used. - Subdomains count as separate domains, so you have to specify all subdomains - used. + :param List[str] origins: An array of strings that contain allowed origin + domains. You have to specify the full URL including the protocol. It is + recommended that only the HTTPS protocol is used. Subdomains count as + separate domains, so you have to specify all subdomains used. :param bool allow_credentials: (optional) Boolean value to allow authentication credentials. If set to true, browser requests must be done by using withCredentials = true. @@ -6669,6 +6597,8 @@ def put_cors_configuration(self, :rtype: DetailedResponse with `dict` result representing a `Ok` object """ + if origins is None: + raise ValueError('origins must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', @@ -7125,8 +7055,8 @@ def get_local_document(self, def put_local_document(self, db: str, doc_id: str, + document: Union['Document', BinaryIO], *, - document: Union['Document', BinaryIO] = None, content_type: str = None, batch: str = None, **kwargs @@ -7140,8 +7070,7 @@ def put_local_document(self, :param str db: Path parameter to specify the database name. :param str doc_id: Path parameter to specify the document ID. - :param Document document: (optional) HTTP request body for Document - operations. + :param Document document: HTTP request body for Document operations. :param str content_type: (optional) The type of the input. :param str batch: (optional) Query parameter to specify whether to store in batch mode. The server will respond with a HTTP 202 Accepted response code @@ -7155,7 +7084,9 @@ def put_local_document(self, raise ValueError('db must be provided') if doc_id is None: raise ValueError('doc_id must be provided') - if document is not None and isinstance(document, Document): + if document is None: + raise ValueError('document must be provided') + if isinstance(document, Document): document = convert_model(document) content_type = content_type or 'application/json' headers = { @@ -7170,7 +7101,7 @@ def put_local_document(self, 'batch': batch } - if document is not None and isinstance(document, dict): + if isinstance(document, dict): data = json.dumps(document) if content_type is None: headers['Content-Type'] = 'application/json' @@ -7198,7 +7129,6 @@ def put_local_document(self, def post_local_docs(self, db: str, *, - accept: str = None, att_encoding_info: bool = None, attachments: bool = None, conflicts: bool = None, @@ -7212,6 +7142,7 @@ def post_local_docs(self, key: str = None, keys: List[str] = None, startkey: str = None, + accept: str = None, **kwargs ) -> DetailedResponse: """ @@ -7225,8 +7156,6 @@ def post_local_docs(self, response. :param str db: Path parameter to specify the database name. - :param str accept: (optional) The type of the response: application/json or - application/octet-stream. :param bool att_encoding_info: (optional) Parameter to specify whether to include the encoding information in attachment stubs if the particular attachment is compressed. @@ -7252,6 +7181,8 @@ def post_local_docs(self, :param str key: (optional) Schema for a document ID. :param List[str] keys: (optional) Schema for a list of document IDs. :param str startkey: (optional) Schema for a document ID. + :param str accept: (optional) The type of the response: application/json or + application/octet-stream. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `AllDocsResult` object @@ -7304,9 +7235,9 @@ def post_local_docs(self, def post_local_docs_queries(self, db: str, + queries: List['AllDocsQuery'], *, accept: str = None, - queries: List['AllDocsQuery'] = None, **kwargs ) -> DetailedResponse: """ @@ -7317,12 +7248,12 @@ def post_local_docs_queries(self, `POST /{db}/_local_docs` requests. :param str db: Path parameter to specify the database name. + :param List[AllDocsQuery] queries: An array of query objects with fields + for the parameters of each individual view query to be executed. The field + names and their meaning are the same as the query parameters of a regular + `/_all_docs` request. :param str accept: (optional) The type of the response: application/json or application/octet-stream. - :param List[AllDocsQuery] queries: (optional) An array of query objects - with fields for the parameters of each individual view query to be - executed. The field names and their meaning are the same as the query - parameters of a regular `/_all_docs` request. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `AllDocsQueriesResult` object @@ -7330,8 +7261,9 @@ def post_local_docs_queries(self, if db is None: raise ValueError('db must be provided') - if queries is not None: - queries = [convert_model(x) for x in queries] + if queries is None: + raise ValueError('queries must be provided') + queries = [convert_model(x) for x in queries] headers = { 'Accept': accept } @@ -7367,53 +7299,9 @@ def post_local_docs_queries(self, ######################### - def post_ensure_full_commit(self, - db: str, - **kwargs - ) -> DetailedResponse: - """ - Commit any recent changes to the specified database to disk. - - Commits any recent changes to the specified database to disk. You must make a - request to this endpoint if you want to ensure that recent changes have been - flushed. This function is likely not required, assuming you have the recommended - configuration setting, `delayed_commits=false`. This setting requires that changes - are written to disk before a 200 or similar result is returned. - - :param str db: Path parameter to specify the database name. - :param dict headers: A `dict` containing the request headers - :return: A `DetailedResponse` containing the result, headers and HTTP status code. - :rtype: DetailedResponse with `dict` result representing a `EnsureFullCommitInformation` object - """ - - if db is None: - raise ValueError('db must be provided') - headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='post_ensure_full_commit') - headers.update(sdk_headers) - - if 'headers' in kwargs: - headers.update(kwargs.get('headers')) - headers['Accept'] = 'application/json' - - path_param_keys = ['db'] - path_param_values = self.encode_path_vars(db) - path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/{db}/_ensure_full_commit'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers) - - response = self.send(request) - return response - - def post_missing_revs(self, db: str, - *, - document_revisions: dict = None, + document_revisions: dict, **kwargs ) -> DetailedResponse: """ @@ -7423,8 +7311,8 @@ def post_missing_revs(self, exist in the database. :param str db: Path parameter to specify the database name. - :param dict document_revisions: (optional) HTTP request body for - postMissingRevs and postRevsDiff. + :param dict document_revisions: HTTP request body for postMissingRevs and + postRevsDiff. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `MissingRevsResult` object @@ -7432,6 +7320,8 @@ def post_missing_revs(self, if db is None: raise ValueError('db must be provided') + if document_revisions is None: + raise ValueError('document_revisions must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', @@ -7460,8 +7350,7 @@ def post_missing_revs(self, def post_revs_diff(self, db: str, - *, - document_revisions: dict = None, + document_revisions: dict, **kwargs ) -> DetailedResponse: """ @@ -7473,8 +7362,8 @@ def post_revs_diff(self, there. It can then avoid fetching and sending already-known document bodies. :param str db: Path parameter to specify the database name. - :param dict document_revisions: (optional) HTTP request body for - postMissingRevs and postRevsDiff. + :param dict document_revisions: HTTP request body for postMissingRevs and + postRevsDiff. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `dict` object @@ -7482,6 +7371,8 @@ def post_revs_diff(self, if db is None: raise ValueError('db must be provided') + if document_revisions is None: + raise ValueError('document_revisions must be provided') headers = {} sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', @@ -8958,19 +8849,19 @@ class BulkDocs(): """ Schema for submitting documents for bulk modifications. - :attr List[Document] docs: (optional) Array of documents. + :attr List[Document] docs: Array of documents. :attr bool new_edits: (optional) If `false`, prevents the database from assigning them new revision IDs. Default is `true`. """ def __init__(self, + docs: List['Document'], *, - docs: List['Document'] = None, new_edits: bool = None) -> None: """ Initialize a BulkDocs object. - :param List[Document] docs: (optional) Array of documents. + :param List[Document] docs: Array of documents. :param bool new_edits: (optional) If `false`, prevents the database from assigning them new revision IDs. Default is `true`. """ @@ -8983,6 +8874,8 @@ def from_dict(cls, _dict: Dict) -> 'BulkDocs': args = {} if 'docs' in _dict: args['docs'] = [Document.from_dict(x) for x in _dict.get('docs')] + else: + raise ValueError('Required property \'docs\' not present in BulkDocs JSON') if 'new_edits' in _dict: args['new_edits'] = _dict.get('new_edits') return cls(**args) @@ -11263,71 +11156,6 @@ def __ne__(self, other: 'DocumentShardInfo') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class EnsureFullCommitInformation(): - """ - Schema for the status of a commit operation. - - :attr str instance_start_time: (optional) Timestamp of when the database was - opened, expressed in microseconds since the epoch. - :attr bool ok: (optional) Operation status. - """ - - def __init__(self, - *, - instance_start_time: str = None, - ok: bool = None) -> None: - """ - Initialize a EnsureFullCommitInformation object. - - :param str instance_start_time: (optional) Timestamp of when the database - was opened, expressed in microseconds since the epoch. - :param bool ok: (optional) Operation status. - """ - self.instance_start_time = instance_start_time - self.ok = ok - - @classmethod - def from_dict(cls, _dict: Dict) -> 'EnsureFullCommitInformation': - """Initialize a EnsureFullCommitInformation object from a json dictionary.""" - args = {} - if 'instance_start_time' in _dict: - args['instance_start_time'] = _dict.get('instance_start_time') - if 'ok' in _dict: - args['ok'] = _dict.get('ok') - return cls(**args) - - @classmethod - def _from_dict(cls, _dict): - """Initialize a EnsureFullCommitInformation object from a json dictionary.""" - return cls.from_dict(_dict) - - def to_dict(self) -> Dict: - """Return a json dictionary representing this model.""" - _dict = {} - if hasattr(self, 'instance_start_time') and self.instance_start_time is not None: - _dict['instance_start_time'] = self.instance_start_time - if hasattr(self, 'ok') and self.ok is not None: - _dict['ok'] = self.ok - return _dict - - def _to_dict(self): - """Return a json dictionary representing this model.""" - return self.to_dict() - - def __str__(self) -> str: - """Return a `str` version of this EnsureFullCommitInformation object.""" - return json.dumps(self.to_dict(), indent=2) - - def __eq__(self, other: 'EnsureFullCommitInformation') -> bool: - """Return `true` when self and other are equal, false otherwise.""" - if not isinstance(other, self.__class__): - return False - return self.__dict__ == other.__dict__ - - def __ne__(self, other: 'EnsureFullCommitInformation') -> bool: - """Return `true` when self and other are not equal, false otherwise.""" - return not self == other - class ExecutionStats(): """ Schema for find query execution statistics. @@ -12234,85 +12062,6 @@ def __ne__(self, other: 'GeoResultRow') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class IamSessionInformation(): - """ - Schema for information about an IAM session. - - :attr str id: (optional) User ID. - :attr bool ok: (optional) Session is ok. - :attr str scope: (optional) Scope of the session. - :attr str type: (optional) Type of the session. - """ - - def __init__(self, - *, - id: str = None, - ok: bool = None, - scope: str = None, - type: str = None) -> None: - """ - Initialize a IamSessionInformation object. - - :param str id: (optional) User ID. - :param bool ok: (optional) Session is ok. - :param str scope: (optional) Scope of the session. - :param str type: (optional) Type of the session. - """ - self.id = id - self.ok = ok - self.scope = scope - self.type = type - - @classmethod - def from_dict(cls, _dict: Dict) -> 'IamSessionInformation': - """Initialize a IamSessionInformation object from a json dictionary.""" - args = {} - if 'id' in _dict: - args['id'] = _dict.get('id') - if 'ok' in _dict: - args['ok'] = _dict.get('ok') - if 'scope' in _dict: - args['scope'] = _dict.get('scope') - if 'type' in _dict: - args['type'] = _dict.get('type') - return cls(**args) - - @classmethod - def _from_dict(cls, _dict): - """Initialize a IamSessionInformation object from a json dictionary.""" - return cls.from_dict(_dict) - - def to_dict(self) -> Dict: - """Return a json dictionary representing this model.""" - _dict = {} - if hasattr(self, 'id') and self.id is not None: - _dict['id'] = self.id - if hasattr(self, 'ok') and self.ok is not None: - _dict['ok'] = self.ok - if hasattr(self, 'scope') and self.scope is not None: - _dict['scope'] = self.scope - if hasattr(self, 'type') and self.type is not None: - _dict['type'] = self.type - return _dict - - def _to_dict(self): - """Return a json dictionary representing this model.""" - return self.to_dict() - - def __str__(self) -> str: - """Return a `str` version of this IamSessionInformation object.""" - return json.dumps(self.to_dict(), indent=2) - - def __eq__(self, other: 'IamSessionInformation') -> bool: - """Return `true` when self and other are equal, false otherwise.""" - if not isinstance(other, self.__class__): - return False - return self.__dict__ == other.__dict__ - - def __ne__(self, other: 'IamSessionInformation') -> bool: - """Return `true` when self and other are not equal, false otherwise.""" - return not self == other - class IndexDefinition(): """ Schema for a `json` or `text` query index definition. Indexes of type `text` have @@ -13499,16 +13248,15 @@ class ReplicationDatabaseAuthIam(): """ Schema for an IAM API key for replication database authentication. - :attr str api_key: (optional) IAM API key. + :attr str api_key: IAM API key. """ def __init__(self, - *, - api_key: str = None) -> None: + api_key: str) -> None: """ Initialize a ReplicationDatabaseAuthIam object. - :param str api_key: (optional) IAM API key. + :param str api_key: IAM API key. """ self.api_key = api_key @@ -13518,6 +13266,8 @@ def from_dict(cls, _dict: Dict) -> 'ReplicationDatabaseAuthIam': args = {} if 'api_key' in _dict: args['api_key'] = _dict.get('api_key') + else: + raise ValueError('Required property \'api_key\' not present in ReplicationDatabaseAuthIam JSON') return cls(**args) @classmethod @@ -13619,12 +13369,12 @@ class ReplicationDocument(): :attr str since_seq: (optional) Start the replication at a specific sequence value. :attr str socket_options: (optional) Replication socket options. - :attr ReplicationDatabase source: (optional) Schema for a replication source or - target database. + :attr ReplicationDatabase source: Schema for a replication source or target + database. :attr str source_proxy: (optional) Address of a (http or socks5 protocol) proxy server through which replication with the source database should occur. - :attr ReplicationDatabase target: (optional) Schema for a replication source or - target database. + :attr ReplicationDatabase target: Schema for a replication source or target + database. :attr str target_proxy: (optional) Address of a (http or socks5 protocol) proxy server through which replication with the target database should occur. :attr bool use_checkpoints: (optional) Specify if checkpoints should be saved @@ -13643,6 +13393,8 @@ class ReplicationDocument(): _properties = frozenset(['attachments', '_attachments', 'conflicts', '_conflicts', 'deleted', '_deleted', 'deleted_conflicts', '_deleted_conflicts', 'id', '_id', 'local_seq', '_local_seq', 'rev', '_rev', 'revisions', '_revisions', 'revs_info', '_revs_info', 'cancel', 'checkpoint_interval', 'connection_timeout', 'continuous', 'create_target', 'create_target_params', 'doc_ids', 'filter', 'http_connections', 'query_params', 'retries_per_request', 'selector', 'since_seq', 'socket_options', 'source', 'source_proxy', 'target', 'target_proxy', 'use_checkpoints', 'user_ctx', 'worker_batch_size', 'worker_processes']) def __init__(self, + source: 'ReplicationDatabase', + target: 'ReplicationDatabase', *, attachments: dict = None, conflicts: List[str] = None, @@ -13667,9 +13419,7 @@ def __init__(self, selector: dict = None, since_seq: str = None, socket_options: str = None, - source: 'ReplicationDatabase' = None, source_proxy: str = None, - target: 'ReplicationDatabase' = None, target_proxy: str = None, use_checkpoints: bool = None, user_ctx: 'UserContext' = None, @@ -13679,6 +13429,10 @@ def __init__(self, """ Initialize a ReplicationDocument object. + :param ReplicationDatabase source: Schema for a replication source or + target database. + :param ReplicationDatabase target: Schema for a replication source or + target database. :param dict attachments: (optional) Schema for a map of attachment name to attachment metadata. :param List[str] conflicts: (optional) Schema for a list of document @@ -13748,13 +13502,9 @@ def __init__(self, :param str since_seq: (optional) Start the replication at a specific sequence value. :param str socket_options: (optional) Replication socket options. - :param ReplicationDatabase source: (optional) Schema for a replication - source or target database. :param str source_proxy: (optional) Address of a (http or socks5 protocol) proxy server through which replication with the source database should occur. - :param ReplicationDatabase target: (optional) Schema for a replication - source or target database. :param str target_proxy: (optional) Address of a (http or socks5 protocol) proxy server through which replication with the target database should occur. @@ -13857,10 +13607,14 @@ def from_dict(cls, _dict: Dict) -> 'ReplicationDocument': args['socket_options'] = _dict.get('socket_options') if 'source' in _dict: args['source'] = ReplicationDatabase.from_dict(_dict.get('source')) + else: + raise ValueError('Required property \'source\' not present in ReplicationDocument JSON') if 'source_proxy' in _dict: args['source_proxy'] = _dict.get('source_proxy') if 'target' in _dict: args['target'] = ReplicationDatabase.from_dict(_dict.get('target')) + else: + raise ValueError('Required property \'target\' not present in ReplicationDocument JSON') if 'target_proxy' in _dict: args['target_proxy'] = _dict.get('target_proxy') if 'use_checkpoints' in _dict: diff --git a/test/unit/test_cloudant_v1.py b/test/unit/test_cloudant_v1.py index 2cb43dfd..1717502a 100644 --- a/test/unit/test_cloudant_v1.py +++ b/test/unit/test_cloudant_v1.py @@ -376,7 +376,7 @@ def test_post_dbs_info_all_params(self): # Invoke method response = service.post_dbs_info( - keys=keys, + keys, headers={} ) @@ -389,9 +389,9 @@ def test_post_dbs_info_all_params(self): @responses.activate - def test_post_dbs_info_required_params(self): + def test_post_dbs_info_value_error(self): """ - test_post_dbs_info_required_params() + test_post_dbs_info_value_error() """ # Set up mock url = self.preprocess_url(base_url + '/_dbs_info') @@ -402,13 +402,18 @@ def test_post_dbs_info_required_params(self): content_type='application/json', status=200) - # Invoke method - response = service.post_dbs_info() + # Set up parameter values + keys = ['testString'] + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "keys": keys, + } + for param in req_param_dict.keys(): + req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} + with pytest.raises(ValueError): + service.post_dbs_info(**req_copy) - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 class TestDeleteDatabase(): @@ -774,16 +779,27 @@ def test_post_changes_required_params(self): # Set up parameter values db = 'testString' + doc_ids = ['testString'] + fields = ['testString'] + selector = {} # Invoke method response = service.post_changes( db, + doc_ids=doc_ids, + fields=fields, + selector=selector, headers={} ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['doc_ids'] == ['testString'] + assert req_body['fields'] == ['testString'] + assert req_body['selector'] == {} @responses.activate @@ -802,6 +818,9 @@ def test_post_changes_value_error(self): # Set up parameter values db = 'testString' + doc_ids = ['testString'] + fields = ['testString'] + selector = {} # Pass in all but one required param and check for a ValueError req_param_dict = { @@ -936,16 +955,27 @@ def test_post_changes_as_stream_required_params(self): # Set up parameter values db = 'testString' + doc_ids = ['testString'] + fields = ['testString'] + selector = {} # Invoke method response = service.post_changes_as_stream( db, + doc_ids=doc_ids, + fields=fields, + selector=selector, headers={} ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['doc_ids'] == ['testString'] + assert req_body['fields'] == ['testString'] + assert req_body['selector'] == {} # Verify streamed JSON response result = response.get_result() @@ -970,6 +1000,9 @@ def test_post_changes_as_stream_value_error(self): # Set up parameter values db = 'testString' + doc_ids = ['testString'] + fields = ['testString'] + selector = {} # Pass in all but one required param and check for a ValueError req_param_dict = { @@ -1170,7 +1203,7 @@ def test_post_document_all_params(self): # Invoke method response = service.post_document( db, - document=document, + document, content_type=content_type, batch=batch, headers={} @@ -1200,18 +1233,56 @@ def test_post_document_required_params(self): content_type='application/json', status=201) + # Construct a dict representation of a Attachment model + attachment_model = {} + attachment_model['content_type'] = 'testString' + attachment_model['data'] = 'VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=' + attachment_model['digest'] = 'testString' + attachment_model['encoded_length'] = 0 + attachment_model['encoding'] = 'testString' + attachment_model['follows'] = True + attachment_model['length'] = 0 + attachment_model['revpos'] = 1 + attachment_model['stub'] = True + + # Construct a dict representation of a Revisions model + revisions_model = {} + revisions_model['ids'] = ['testString'] + revisions_model['start'] = 1 + + # Construct a dict representation of a DocumentRevisionStatus model + document_revision_status_model = {} + document_revision_status_model['rev'] = 'testString' + document_revision_status_model['status'] = 'available' + + # Construct a dict representation of a Document model + document_model = {} + document_model['_attachments'] = {} + document_model['_conflicts'] = ['testString'] + document_model['_deleted'] = True + document_model['_deleted_conflicts'] = ['testString'] + document_model['_id'] = 'testString' + document_model['_local_seq'] = 'testString' + document_model['_rev'] = 'testString' + document_model['_revisions'] = revisions_model + document_model['_revs_info'] = [document_revision_status_model] + document_model['foo'] = { 'foo': 'bar' } + # Set up parameter values db = 'testString' + document = document_model # Invoke method response = service.post_document( db, + document, headers={} ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 201 + # Validate body params @responses.activate @@ -1228,12 +1299,49 @@ def test_post_document_value_error(self): content_type='application/json', status=201) + # Construct a dict representation of a Attachment model + attachment_model = {} + attachment_model['content_type'] = 'testString' + attachment_model['data'] = 'VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=' + attachment_model['digest'] = 'testString' + attachment_model['encoded_length'] = 0 + attachment_model['encoding'] = 'testString' + attachment_model['follows'] = True + attachment_model['length'] = 0 + attachment_model['revpos'] = 1 + attachment_model['stub'] = True + + # Construct a dict representation of a Revisions model + revisions_model = {} + revisions_model['ids'] = ['testString'] + revisions_model['start'] = 1 + + # Construct a dict representation of a DocumentRevisionStatus model + document_revision_status_model = {} + document_revision_status_model['rev'] = 'testString' + document_revision_status_model['status'] = 'available' + + # Construct a dict representation of a Document model + document_model = {} + document_model['_attachments'] = {} + document_model['_conflicts'] = ['testString'] + document_model['_deleted'] = True + document_model['_deleted_conflicts'] = ['testString'] + document_model['_id'] = 'testString' + document_model['_local_seq'] = 'testString' + document_model['_rev'] = 'testString' + document_model['_revisions'] = revisions_model + document_model['_revs_info'] = [document_revision_status_model] + document_model['foo'] = { 'foo': 'bar' } + # Set up parameter values db = 'testString' + document = document_model # Pass in all but one required param and check for a ValueError req_param_dict = { "db": db, + "document": document, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -1325,34 +1433,6 @@ def test_post_all_docs_all_params(self): assert req_body['startkey'] == 'testString' - @responses.activate - def test_post_all_docs_required_params(self): - """ - test_post_all_docs_required_params() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_all_docs') - mock_response = '{"total_rows": 0, "rows": [{"caused_by": "caused_by", "error": "error", "reason": "reason", "doc": {"_attachments": {"mapKey": {"content_type": "content_type", "data": "VGhpcyBpcyBhbiBlbmNvZGVkIGJ5dGUgYXJyYXku", "digest": "digest", "encoded_length": 0, "encoding": "encoding", "follows": false, "length": 0, "revpos": 1, "stub": true}}, "_conflicts": ["conflicts"], "_deleted": false, "_deleted_conflicts": ["deleted_conflicts"], "_id": "id", "_local_seq": "local_seq", "_rev": "rev", "_revisions": {"ids": ["ids"], "start": 1}, "_revs_info": [{"rev": "rev", "status": "available"}]}, "id": "id", "key": "key", "value": {"rev": "rev"}}], "update_seq": "update_seq"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Set up parameter values - db = 'testString' - - # Invoke method - response = service.post_all_docs( - db, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - @responses.activate def test_post_all_docs_value_error(self): """ @@ -1369,6 +1449,19 @@ def test_post_all_docs_value_error(self): # Set up parameter values db = 'testString' + att_encoding_info = True + attachments = True + conflicts = True + descending = True + include_docs = True + inclusive_end = True + limit = 0 + skip = 0 + update_seq = True + endkey = 'testString' + key = 'testString' + keys = ['testString'] + startkey = 'testString' # Pass in all but one required param and check for a ValueError req_param_dict = { @@ -1470,40 +1563,6 @@ def test_post_all_docs_as_stream_all_params(self): assert str(next(response_buf), "utf-8") == mock_response - @responses.activate - def test_post_all_docs_as_stream_required_params(self): - """ - test_post_all_docs_as_stream_required_params() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_all_docs') - mock_response = '{"foo": "this is a mock response for JSON streaming"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Set up parameter values - db = 'testString' - - # Invoke method - response = service.post_all_docs_as_stream( - db, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - # Verify streamed JSON response - result = response.get_result() - assert isinstance(result, requests.models.Response) - response_buf = result.iter_content(chunk_size=1024) - assert str(next(response_buf), "utf-8") == mock_response - - @responses.activate def test_post_all_docs_as_stream_value_error(self): """ @@ -1520,6 +1579,19 @@ def test_post_all_docs_as_stream_value_error(self): # Set up parameter values db = 'testString' + att_encoding_info = True + attachments = True + conflicts = True + descending = True + include_docs = True + inclusive_end = True + limit = 0 + skip = 0 + update_seq = True + endkey = 'testString' + key = 'testString' + keys = ['testString'] + startkey = 'testString' # Pass in all but one required param and check for a ValueError req_param_dict = { @@ -1583,7 +1655,7 @@ def test_post_all_docs_queries_all_params(self): # Invoke method response = service.post_all_docs_queries( db, - queries=queries, + queries, headers={} ) @@ -1595,34 +1667,6 @@ def test_post_all_docs_queries_all_params(self): assert req_body['queries'] == [all_docs_query_model] - @responses.activate - def test_post_all_docs_queries_required_params(self): - """ - test_post_all_docs_queries_required_params() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_all_docs/queries') - mock_response = '{"results": [{"total_rows": 0, "rows": [{"caused_by": "caused_by", "error": "error", "reason": "reason", "doc": {"_attachments": {"mapKey": {"content_type": "content_type", "data": "VGhpcyBpcyBhbiBlbmNvZGVkIGJ5dGUgYXJyYXku", "digest": "digest", "encoded_length": 0, "encoding": "encoding", "follows": false, "length": 0, "revpos": 1, "stub": true}}, "_conflicts": ["conflicts"], "_deleted": false, "_deleted_conflicts": ["deleted_conflicts"], "_id": "id", "_local_seq": "local_seq", "_rev": "rev", "_revisions": {"ids": ["ids"], "start": 1}, "_revs_info": [{"rev": "rev", "status": "available"}]}, "id": "id", "key": "key", "value": {"rev": "rev"}}], "update_seq": "update_seq"}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Set up parameter values - db = 'testString' - - # Invoke method - response = service.post_all_docs_queries( - db, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - @responses.activate def test_post_all_docs_queries_value_error(self): """ @@ -1637,12 +1681,30 @@ def test_post_all_docs_queries_value_error(self): content_type='application/json', status=200) + # Construct a dict representation of a AllDocsQuery model + all_docs_query_model = {} + all_docs_query_model['att_encoding_info'] = True + all_docs_query_model['attachments'] = True + all_docs_query_model['conflicts'] = True + all_docs_query_model['descending'] = True + all_docs_query_model['include_docs'] = True + all_docs_query_model['inclusive_end'] = True + all_docs_query_model['limit'] = 0 + all_docs_query_model['skip'] = 0 + all_docs_query_model['update_seq'] = True + all_docs_query_model['endkey'] = 'testString' + all_docs_query_model['key'] = 'testString' + all_docs_query_model['keys'] = ['testString'] + all_docs_query_model['startkey'] = 'testString' + # Set up parameter values db = 'testString' + queries = [all_docs_query_model] # Pass in all but one required param and check for a ValueError req_param_dict = { "db": db, + "queries": queries, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -1702,7 +1764,7 @@ def test_post_all_docs_queries_as_stream_all_params(self): # Invoke method response = service.post_all_docs_queries_as_stream( db, - queries=queries, + queries, headers={} ) @@ -1721,9 +1783,9 @@ def test_post_all_docs_queries_as_stream_all_params(self): @responses.activate - def test_post_all_docs_queries_as_stream_required_params(self): + def test_post_all_docs_queries_as_stream_value_error(self): """ - test_post_all_docs_queries_as_stream_required_params() + test_post_all_docs_queries_as_stream_value_error() """ # Set up mock url = self.preprocess_url(base_url + '/testString/_all_docs/queries') @@ -1734,46 +1796,30 @@ def test_post_all_docs_queries_as_stream_required_params(self): content_type='application/json', status=200) - # Set up parameter values - db = 'testString' - - # Invoke method - response = service.post_all_docs_queries_as_stream( - db, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - # Verify streamed JSON response - result = response.get_result() - assert isinstance(result, requests.models.Response) - response_buf = result.iter_content(chunk_size=1024) - assert str(next(response_buf), "utf-8") == mock_response - - - @responses.activate - def test_post_all_docs_queries_as_stream_value_error(self): - """ - test_post_all_docs_queries_as_stream_value_error() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_all_docs/queries') - mock_response = '{"foo": "this is a mock response for JSON streaming"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + # Construct a dict representation of a AllDocsQuery model + all_docs_query_model = {} + all_docs_query_model['att_encoding_info'] = True + all_docs_query_model['attachments'] = True + all_docs_query_model['conflicts'] = True + all_docs_query_model['descending'] = True + all_docs_query_model['include_docs'] = True + all_docs_query_model['inclusive_end'] = True + all_docs_query_model['limit'] = 0 + all_docs_query_model['skip'] = 0 + all_docs_query_model['update_seq'] = True + all_docs_query_model['endkey'] = 'testString' + all_docs_query_model['key'] = 'testString' + all_docs_query_model['keys'] = ['testString'] + all_docs_query_model['startkey'] = 'testString' # Set up parameter values db = 'testString' + queries = [all_docs_query_model] # Pass in all but one required param and check for a ValueError req_param_dict = { "db": db, + "queries": queries, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -1857,7 +1903,7 @@ def test_post_bulk_docs_all_params(self): # Invoke method response = service.post_bulk_docs( db, - bulk_docs=bulk_docs, + bulk_docs, headers={} ) @@ -1870,9 +1916,9 @@ def test_post_bulk_docs_all_params(self): @responses.activate - def test_post_bulk_docs_required_params(self): + def test_post_bulk_docs_value_error(self): """ - test_post_bulk_docs_required_params() + test_post_bulk_docs_value_error() """ # Set up mock url = self.preprocess_url(base_url + '/testString/_bulk_docs') @@ -1883,40 +1929,54 @@ def test_post_bulk_docs_required_params(self): content_type='application/json', status=201) - # Set up parameter values - db = 'testString' + # Construct a dict representation of a Attachment model + attachment_model = {} + attachment_model['content_type'] = 'testString' + attachment_model['data'] = 'VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=' + attachment_model['digest'] = 'testString' + attachment_model['encoded_length'] = 0 + attachment_model['encoding'] = 'testString' + attachment_model['follows'] = True + attachment_model['length'] = 0 + attachment_model['revpos'] = 1 + attachment_model['stub'] = True - # Invoke method - response = service.post_bulk_docs( - db, - headers={} - ) + # Construct a dict representation of a Revisions model + revisions_model = {} + revisions_model['ids'] = ['testString'] + revisions_model['start'] = 1 - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 201 + # Construct a dict representation of a DocumentRevisionStatus model + document_revision_status_model = {} + document_revision_status_model['rev'] = 'testString' + document_revision_status_model['status'] = 'available' + # Construct a dict representation of a Document model + document_model = {} + document_model['_attachments'] = {} + document_model['_conflicts'] = ['testString'] + document_model['_deleted'] = True + document_model['_deleted_conflicts'] = ['testString'] + document_model['_id'] = 'testString' + document_model['_local_seq'] = 'testString' + document_model['_rev'] = 'testString' + document_model['_revisions'] = revisions_model + document_model['_revs_info'] = [document_revision_status_model] + document_model['foo'] = { 'foo': 'bar' } - @responses.activate - def test_post_bulk_docs_value_error(self): - """ - test_post_bulk_docs_value_error() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_bulk_docs') - mock_response = '[{"id": "id", "rev": "rev", "ok": true, "caused_by": "caused_by", "error": "error", "reason": "reason"}]' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + # Construct a dict representation of a BulkDocs model + bulk_docs_model = {} + bulk_docs_model['docs'] = [document_model] + bulk_docs_model['new_edits'] = True # Set up parameter values db = 'testString' + bulk_docs = bulk_docs_model # Pass in all but one required param and check for a ValueError req_param_dict = { "db": db, + "bulk_docs": bulk_docs, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -1971,7 +2031,7 @@ def test_post_bulk_get_all_params(self): # Invoke method response = service.post_bulk_get( db, - docs=docs, + docs, attachments=attachments, att_encoding_info=att_encoding_info, latest=latest, @@ -2008,18 +2068,30 @@ def test_post_bulk_get_required_params(self): content_type='application/json', status=200) + # Construct a dict representation of a BulkGetQueryDocument model + bulk_get_query_document_model = {} + bulk_get_query_document_model['atts_since'] = ['testString'] + bulk_get_query_document_model['id'] = 'testString' + bulk_get_query_document_model['open_revs'] = ['testString'] + bulk_get_query_document_model['rev'] = 'testString' + # Set up parameter values db = 'testString' + docs = [bulk_get_query_document_model] # Invoke method response = service.post_bulk_get( db, + docs, headers={} ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['docs'] == [bulk_get_query_document_model] @responses.activate @@ -2036,12 +2108,21 @@ def test_post_bulk_get_value_error(self): content_type='application/json', status=200) + # Construct a dict representation of a BulkGetQueryDocument model + bulk_get_query_document_model = {} + bulk_get_query_document_model['atts_since'] = ['testString'] + bulk_get_query_document_model['id'] = 'testString' + bulk_get_query_document_model['open_revs'] = ['testString'] + bulk_get_query_document_model['rev'] = 'testString' + # Set up parameter values db = 'testString' + docs = [bulk_get_query_document_model] # Pass in all but one required param and check for a ValueError req_param_dict = { "db": db, + "docs": docs, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -2096,7 +2177,7 @@ def test_post_bulk_get_as_mixed_all_params(self): # Invoke method response = service.post_bulk_get_as_mixed( db, - docs=docs, + docs, attachments=attachments, att_encoding_info=att_encoding_info, latest=latest, @@ -2133,18 +2214,30 @@ def test_post_bulk_get_as_mixed_required_params(self): content_type='multipart/mixed', status=200) + # Construct a dict representation of a BulkGetQueryDocument model + bulk_get_query_document_model = {} + bulk_get_query_document_model['atts_since'] = ['testString'] + bulk_get_query_document_model['id'] = 'foo' + bulk_get_query_document_model['open_revs'] = ['testString'] + bulk_get_query_document_model['rev'] = '4-753875d51501a6b1883a9d62b4d33f91' + # Set up parameter values db = 'testString' + docs = [bulk_get_query_document_model] # Invoke method response = service.post_bulk_get_as_mixed( db, + docs, headers={} ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['docs'] == [bulk_get_query_document_model] @responses.activate @@ -2161,12 +2254,21 @@ def test_post_bulk_get_as_mixed_value_error(self): content_type='multipart/mixed', status=200) + # Construct a dict representation of a BulkGetQueryDocument model + bulk_get_query_document_model = {} + bulk_get_query_document_model['atts_since'] = ['testString'] + bulk_get_query_document_model['id'] = 'foo' + bulk_get_query_document_model['open_revs'] = ['testString'] + bulk_get_query_document_model['rev'] = '4-753875d51501a6b1883a9d62b4d33f91' + # Set up parameter values db = 'testString' + docs = [bulk_get_query_document_model] # Pass in all but one required param and check for a ValueError req_param_dict = { "db": db, + "docs": docs, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -2221,7 +2323,7 @@ def test_post_bulk_get_as_related_all_params(self): # Invoke method response = service.post_bulk_get_as_related( db, - docs=docs, + docs, attachments=attachments, att_encoding_info=att_encoding_info, latest=latest, @@ -2258,18 +2360,30 @@ def test_post_bulk_get_as_related_required_params(self): content_type='multipart/related', status=200) + # Construct a dict representation of a BulkGetQueryDocument model + bulk_get_query_document_model = {} + bulk_get_query_document_model['atts_since'] = ['testString'] + bulk_get_query_document_model['id'] = 'foo' + bulk_get_query_document_model['open_revs'] = ['testString'] + bulk_get_query_document_model['rev'] = '4-753875d51501a6b1883a9d62b4d33f91' + # Set up parameter values db = 'testString' + docs = [bulk_get_query_document_model] # Invoke method response = service.post_bulk_get_as_related( db, + docs, headers={} ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['docs'] == [bulk_get_query_document_model] @responses.activate @@ -2286,12 +2400,21 @@ def test_post_bulk_get_as_related_value_error(self): content_type='multipart/related', status=200) + # Construct a dict representation of a BulkGetQueryDocument model + bulk_get_query_document_model = {} + bulk_get_query_document_model['atts_since'] = ['testString'] + bulk_get_query_document_model['id'] = 'foo' + bulk_get_query_document_model['open_revs'] = ['testString'] + bulk_get_query_document_model['rev'] = '4-753875d51501a6b1883a9d62b4d33f91' + # Set up parameter values db = 'testString' + docs = [bulk_get_query_document_model] # Pass in all but one required param and check for a ValueError req_param_dict = { "db": db, + "docs": docs, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -2346,7 +2469,7 @@ def test_post_bulk_get_as_stream_all_params(self): # Invoke method response = service.post_bulk_get_as_stream( db, - docs=docs, + docs, attachments=attachments, att_encoding_info=att_encoding_info, latest=latest, @@ -2389,18 +2512,30 @@ def test_post_bulk_get_as_stream_required_params(self): content_type='application/json', status=200) + # Construct a dict representation of a BulkGetQueryDocument model + bulk_get_query_document_model = {} + bulk_get_query_document_model['atts_since'] = ['testString'] + bulk_get_query_document_model['id'] = 'foo' + bulk_get_query_document_model['open_revs'] = ['testString'] + bulk_get_query_document_model['rev'] = '4-753875d51501a6b1883a9d62b4d33f91' + # Set up parameter values db = 'testString' + docs = [bulk_get_query_document_model] # Invoke method response = service.post_bulk_get_as_stream( db, + docs, headers={} ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['docs'] == [bulk_get_query_document_model] # Verify streamed JSON response result = response.get_result() @@ -2423,12 +2558,21 @@ def test_post_bulk_get_as_stream_value_error(self): content_type='application/json', status=200) + # Construct a dict representation of a BulkGetQueryDocument model + bulk_get_query_document_model = {} + bulk_get_query_document_model['atts_since'] = ['testString'] + bulk_get_query_document_model['id'] = 'foo' + bulk_get_query_document_model['open_revs'] = ['testString'] + bulk_get_query_document_model['rev'] = '4-753875d51501a6b1883a9d62b4d33f91' + # Set up parameter values db = 'testString' + docs = [bulk_get_query_document_model] # Pass in all but one required param and check for a ValueError req_param_dict = { "db": db, + "docs": docs, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -3221,7 +3365,7 @@ def test_put_document_all_params(self): response = service.put_document( db, doc_id, - document=document, + document, content_type=content_type, if_match=if_match, batch=batch, @@ -3256,20 +3400,58 @@ def test_put_document_required_params(self): content_type='application/json', status=201) + # Construct a dict representation of a Attachment model + attachment_model = {} + attachment_model['content_type'] = 'testString' + attachment_model['data'] = 'VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=' + attachment_model['digest'] = 'testString' + attachment_model['encoded_length'] = 0 + attachment_model['encoding'] = 'testString' + attachment_model['follows'] = True + attachment_model['length'] = 0 + attachment_model['revpos'] = 1 + attachment_model['stub'] = True + + # Construct a dict representation of a Revisions model + revisions_model = {} + revisions_model['ids'] = ['testString'] + revisions_model['start'] = 1 + + # Construct a dict representation of a DocumentRevisionStatus model + document_revision_status_model = {} + document_revision_status_model['rev'] = 'testString' + document_revision_status_model['status'] = 'available' + + # Construct a dict representation of a Document model + document_model = {} + document_model['_attachments'] = {} + document_model['_conflicts'] = ['testString'] + document_model['_deleted'] = True + document_model['_deleted_conflicts'] = ['testString'] + document_model['_id'] = 'testString' + document_model['_local_seq'] = 'testString' + document_model['_rev'] = 'testString' + document_model['_revisions'] = revisions_model + document_model['_revs_info'] = [document_revision_status_model] + document_model['foo'] = { 'foo': 'bar' } + # Set up parameter values db = 'testString' doc_id = 'testString' + document = document_model # Invoke method response = service.put_document( db, doc_id, + document, headers={} ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 201 + # Validate body params @responses.activate @@ -3286,14 +3468,51 @@ def test_put_document_value_error(self): content_type='application/json', status=201) + # Construct a dict representation of a Attachment model + attachment_model = {} + attachment_model['content_type'] = 'testString' + attachment_model['data'] = 'VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=' + attachment_model['digest'] = 'testString' + attachment_model['encoded_length'] = 0 + attachment_model['encoding'] = 'testString' + attachment_model['follows'] = True + attachment_model['length'] = 0 + attachment_model['revpos'] = 1 + attachment_model['stub'] = True + + # Construct a dict representation of a Revisions model + revisions_model = {} + revisions_model['ids'] = ['testString'] + revisions_model['start'] = 1 + + # Construct a dict representation of a DocumentRevisionStatus model + document_revision_status_model = {} + document_revision_status_model['rev'] = 'testString' + document_revision_status_model['status'] = 'available' + + # Construct a dict representation of a Document model + document_model = {} + document_model['_attachments'] = {} + document_model['_conflicts'] = ['testString'] + document_model['_deleted'] = True + document_model['_deleted_conflicts'] = ['testString'] + document_model['_id'] = 'testString' + document_model['_local_seq'] = 'testString' + document_model['_rev'] = 'testString' + document_model['_revisions'] = revisions_model + document_model['_revs_info'] = [document_revision_status_model] + document_model['foo'] = { 'foo': 'bar' } + # Set up parameter values db = 'testString' doc_id = 'testString' + document = document_model # Pass in all but one required param and check for a ValueError req_param_dict = { "db": db, "doc_id": doc_id, + "document": document, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -3783,7 +4002,7 @@ def test_put_design_document_all_params(self): response = service.put_design_document( db, ddoc, - design_document=design_document, + design_document, if_match=if_match, batch=batch, new_edits=new_edits, @@ -3819,20 +4038,98 @@ def test_put_design_document_required_params(self): content_type='application/json', status=201) - # Set up parameter values - db = 'testString' - ddoc = 'testString' - - # Invoke method - response = service.put_design_document( - db, - ddoc, - headers={} - ) + # Construct a dict representation of a Attachment model + attachment_model = {} + attachment_model['content_type'] = 'testString' + attachment_model['data'] = 'VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=' + attachment_model['digest'] = 'testString' + attachment_model['encoded_length'] = 0 + attachment_model['encoding'] = 'testString' + attachment_model['follows'] = True + attachment_model['length'] = 0 + attachment_model['revpos'] = 1 + attachment_model['stub'] = True + + # Construct a dict representation of a Revisions model + revisions_model = {} + revisions_model['ids'] = ['testString'] + revisions_model['start'] = 1 + + # Construct a dict representation of a DocumentRevisionStatus model + document_revision_status_model = {} + document_revision_status_model['rev'] = 'testString' + document_revision_status_model['status'] = 'available' + + # Construct a dict representation of a Analyzer model + analyzer_model = {} + analyzer_model['name'] = 'classic' + analyzer_model['stopwords'] = ['testString'] + + # Construct a dict representation of a AnalyzerConfiguration model + analyzer_configuration_model = {} + analyzer_configuration_model['name'] = 'classic' + analyzer_configuration_model['stopwords'] = ['testString'] + analyzer_configuration_model['fields'] = {} + + # Construct a dict representation of a SearchIndexDefinition model + search_index_definition_model = {} + search_index_definition_model['analyzer'] = analyzer_configuration_model + search_index_definition_model['index'] = 'testString' + + # Construct a dict representation of a DesignDocumentOptions model + design_document_options_model = {} + design_document_options_model['partitioned'] = True + + # Construct a dict representation of a DesignDocumentViewsMapReduce model + design_document_views_map_reduce_model = {} + design_document_views_map_reduce_model['map'] = 'testString' + design_document_views_map_reduce_model['reduce'] = 'testString' + + # Construct a dict representation of a GeoIndexDefinition model + geo_index_definition_model = {} + geo_index_definition_model['index'] = 'testString' + + # Construct a dict representation of a DesignDocument model + design_document_model = {} + design_document_model['_attachments'] = {} + design_document_model['_conflicts'] = ['testString'] + design_document_model['_deleted'] = True + design_document_model['_deleted_conflicts'] = ['testString'] + design_document_model['_id'] = 'testString' + design_document_model['_local_seq'] = 'testString' + design_document_model['_rev'] = 'testString' + design_document_model['_revisions'] = revisions_model + design_document_model['_revs_info'] = [document_revision_status_model] + design_document_model['autoupdate'] = True + design_document_model['filters'] = {} + design_document_model['indexes'] = {} + design_document_model['language'] = 'testString' + design_document_model['options'] = design_document_options_model + design_document_model['updates'] = {} + design_document_model['validate_doc_update'] = {} + design_document_model['views'] = {} + design_document_model['st_indexes'] = {} + design_document_model['foo'] = { 'foo': 'bar' } + + # Set up parameter values + db = 'testString' + ddoc = 'testString' + design_document = design_document_model + + # Invoke method + response = service.put_design_document( + db, + ddoc, + design_document, + headers={} + ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 201 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body == design_document @responses.activate @@ -3849,14 +4146,89 @@ def test_put_design_document_value_error(self): content_type='application/json', status=201) + # Construct a dict representation of a Attachment model + attachment_model = {} + attachment_model['content_type'] = 'testString' + attachment_model['data'] = 'VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=' + attachment_model['digest'] = 'testString' + attachment_model['encoded_length'] = 0 + attachment_model['encoding'] = 'testString' + attachment_model['follows'] = True + attachment_model['length'] = 0 + attachment_model['revpos'] = 1 + attachment_model['stub'] = True + + # Construct a dict representation of a Revisions model + revisions_model = {} + revisions_model['ids'] = ['testString'] + revisions_model['start'] = 1 + + # Construct a dict representation of a DocumentRevisionStatus model + document_revision_status_model = {} + document_revision_status_model['rev'] = 'testString' + document_revision_status_model['status'] = 'available' + + # Construct a dict representation of a Analyzer model + analyzer_model = {} + analyzer_model['name'] = 'classic' + analyzer_model['stopwords'] = ['testString'] + + # Construct a dict representation of a AnalyzerConfiguration model + analyzer_configuration_model = {} + analyzer_configuration_model['name'] = 'classic' + analyzer_configuration_model['stopwords'] = ['testString'] + analyzer_configuration_model['fields'] = {} + + # Construct a dict representation of a SearchIndexDefinition model + search_index_definition_model = {} + search_index_definition_model['analyzer'] = analyzer_configuration_model + search_index_definition_model['index'] = 'testString' + + # Construct a dict representation of a DesignDocumentOptions model + design_document_options_model = {} + design_document_options_model['partitioned'] = True + + # Construct a dict representation of a DesignDocumentViewsMapReduce model + design_document_views_map_reduce_model = {} + design_document_views_map_reduce_model['map'] = 'testString' + design_document_views_map_reduce_model['reduce'] = 'testString' + + # Construct a dict representation of a GeoIndexDefinition model + geo_index_definition_model = {} + geo_index_definition_model['index'] = 'testString' + + # Construct a dict representation of a DesignDocument model + design_document_model = {} + design_document_model['_attachments'] = {} + design_document_model['_conflicts'] = ['testString'] + design_document_model['_deleted'] = True + design_document_model['_deleted_conflicts'] = ['testString'] + design_document_model['_id'] = 'testString' + design_document_model['_local_seq'] = 'testString' + design_document_model['_rev'] = 'testString' + design_document_model['_revisions'] = revisions_model + design_document_model['_revs_info'] = [document_revision_status_model] + design_document_model['autoupdate'] = True + design_document_model['filters'] = {} + design_document_model['indexes'] = {} + design_document_model['language'] = 'testString' + design_document_model['options'] = design_document_options_model + design_document_model['updates'] = {} + design_document_model['validate_doc_update'] = {} + design_document_model['views'] = {} + design_document_model['st_indexes'] = {} + design_document_model['foo'] = { 'foo': 'bar' } + # Set up parameter values db = 'testString' ddoc = 'testString' + design_document = design_document_model # Pass in all but one required param and check for a ValueError req_param_dict = { "db": db, "ddoc": ddoc, + "design_document": design_document, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -3969,7 +4341,6 @@ def test_post_design_docs_all_params(self): # Set up parameter values db = 'testString' - accept = 'application/json' att_encoding_info = True attachments = True conflicts = True @@ -3983,11 +4354,11 @@ def test_post_design_docs_all_params(self): key = 'testString' keys = ['testString'] startkey = 'testString' + accept = 'application/json' # Invoke method response = service.post_design_docs( db, - accept=accept, att_encoding_info=att_encoding_info, attachments=attachments, conflicts=conflicts, @@ -4001,6 +4372,7 @@ def test_post_design_docs_all_params(self): key=key, keys=keys, startkey=startkey, + accept=accept, headers={} ) @@ -4040,16 +4412,57 @@ def test_post_design_docs_required_params(self): # Set up parameter values db = 'testString' + att_encoding_info = True + attachments = True + conflicts = True + descending = True + include_docs = True + inclusive_end = True + limit = 0 + skip = 0 + update_seq = True + endkey = 'testString' + key = 'testString' + keys = ['testString'] + startkey = 'testString' # Invoke method response = service.post_design_docs( db, + att_encoding_info=att_encoding_info, + attachments=attachments, + conflicts=conflicts, + descending=descending, + include_docs=include_docs, + inclusive_end=inclusive_end, + limit=limit, + skip=skip, + update_seq=update_seq, + endkey=endkey, + key=key, + keys=keys, + startkey=startkey, headers={} ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['att_encoding_info'] == True + assert req_body['attachments'] == True + assert req_body['conflicts'] == True + assert req_body['descending'] == True + assert req_body['include_docs'] == True + assert req_body['inclusive_end'] == True + assert req_body['limit'] == 0 + assert req_body['skip'] == 0 + assert req_body['update_seq'] == True + assert req_body['endkey'] == 'testString' + assert req_body['key'] == 'testString' + assert req_body['keys'] == ['testString'] + assert req_body['startkey'] == 'testString' @responses.activate @@ -4068,6 +4481,19 @@ def test_post_design_docs_value_error(self): # Set up parameter values db = 'testString' + att_encoding_info = True + attachments = True + conflicts = True + descending = True + include_docs = True + inclusive_end = True + limit = 0 + skip = 0 + update_seq = True + endkey = 'testString' + key = 'testString' + keys = ['testString'] + startkey = 'testString' # Pass in all but one required param and check for a ValueError req_param_dict = { @@ -4126,14 +4552,14 @@ def test_post_design_docs_queries_all_params(self): # Set up parameter values db = 'testString' - accept = 'application/json' queries = [all_docs_query_model] + accept = 'application/json' # Invoke method response = service.post_design_docs_queries( db, + queries, accept=accept, - queries=queries, headers={} ) @@ -4159,18 +4585,39 @@ def test_post_design_docs_queries_required_params(self): content_type='application/json', status=200) + # Construct a dict representation of a AllDocsQuery model + all_docs_query_model = {} + all_docs_query_model['att_encoding_info'] = True + all_docs_query_model['attachments'] = True + all_docs_query_model['conflicts'] = True + all_docs_query_model['descending'] = True + all_docs_query_model['include_docs'] = True + all_docs_query_model['inclusive_end'] = True + all_docs_query_model['limit'] = 0 + all_docs_query_model['skip'] = 0 + all_docs_query_model['update_seq'] = True + all_docs_query_model['endkey'] = 'testString' + all_docs_query_model['key'] = 'testString' + all_docs_query_model['keys'] = ['testString'] + all_docs_query_model['startkey'] = 'testString' + # Set up parameter values db = 'testString' + queries = [all_docs_query_model] # Invoke method response = service.post_design_docs_queries( db, + queries, headers={} ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['queries'] == [all_docs_query_model] @responses.activate @@ -4187,12 +4634,30 @@ def test_post_design_docs_queries_value_error(self): content_type='application/json', status=200) + # Construct a dict representation of a AllDocsQuery model + all_docs_query_model = {} + all_docs_query_model['att_encoding_info'] = True + all_docs_query_model['attachments'] = True + all_docs_query_model['conflicts'] = True + all_docs_query_model['descending'] = True + all_docs_query_model['include_docs'] = True + all_docs_query_model['inclusive_end'] = True + all_docs_query_model['limit'] = 0 + all_docs_query_model['skip'] = 0 + all_docs_query_model['update_seq'] = True + all_docs_query_model['endkey'] = 'testString' + all_docs_query_model['key'] = 'testString' + all_docs_query_model['keys'] = ['testString'] + all_docs_query_model['startkey'] = 'testString' + # Set up parameter values db = 'testString' + queries = [all_docs_query_model] # Pass in all but one required param and check for a ValueError req_param_dict = { "db": db, + "queries": queries, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -4319,38 +4784,6 @@ def test_post_view_all_params(self): assert req_body['update'] == 'true' - @responses.activate - def test_post_view_required_params(self): - """ - test_post_view_required_params() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_design/testString/_view/testString') - mock_response = '{"total_rows": 0, "update_seq": "update_seq", "rows": [{"caused_by": "caused_by", "error": "error", "reason": "reason", "doc": {"_attachments": {"mapKey": {"content_type": "content_type", "data": "VGhpcyBpcyBhbiBlbmNvZGVkIGJ5dGUgYXJyYXku", "digest": "digest", "encoded_length": 0, "encoding": "encoding", "follows": false, "length": 0, "revpos": 1, "stub": true}}, "_conflicts": ["conflicts"], "_deleted": false, "_deleted_conflicts": ["deleted_conflicts"], "_id": "id", "_local_seq": "local_seq", "_rev": "rev", "_revisions": {"ids": ["ids"], "start": 1}, "_revs_info": [{"rev": "rev", "status": "available"}]}, "id": "id", "key": {"anyKey": "anyValue"}, "value": {"anyKey": "anyValue"}}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Set up parameter values - db = 'testString' - ddoc = 'testString' - view = 'testString' - - # Invoke method - response = service.post_view( - db, - ddoc, - view, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - @responses.activate def test_post_view_value_error(self): """ @@ -4369,6 +4802,26 @@ def test_post_view_value_error(self): db = 'testString' ddoc = 'testString' view = 'testString' + att_encoding_info = True + attachments = True + conflicts = True + descending = True + include_docs = True + inclusive_end = True + limit = 0 + skip = 0 + update_seq = True + endkey = { 'foo': 'bar' } + endkey_docid = 'testString' + group = True + group_level = 1 + key = { 'foo': 'bar' } + keys = [{ 'foo': 'bar' }] + reduce = True + stable = True + startkey = { 'foo': 'bar' } + startkey_docid = 'testString' + update = 'true' # Pass in all but one required param and check for a ValueError req_param_dict = { @@ -4497,44 +4950,6 @@ def test_post_view_as_stream_all_params(self): assert str(next(response_buf), "utf-8") == mock_response - @responses.activate - def test_post_view_as_stream_required_params(self): - """ - test_post_view_as_stream_required_params() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_design/testString/_view/testString') - mock_response = '{"foo": "this is a mock response for JSON streaming"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Set up parameter values - db = 'testString' - ddoc = 'testString' - view = 'testString' - - # Invoke method - response = service.post_view_as_stream( - db, - ddoc, - view, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - # Verify streamed JSON response - result = response.get_result() - assert isinstance(result, requests.models.Response) - response_buf = result.iter_content(chunk_size=1024) - assert str(next(response_buf), "utf-8") == mock_response - - @responses.activate def test_post_view_as_stream_value_error(self): """ @@ -4553,6 +4968,26 @@ def test_post_view_as_stream_value_error(self): db = 'testString' ddoc = 'testString' view = 'testString' + att_encoding_info = True + attachments = True + conflicts = True + descending = True + include_docs = True + inclusive_end = True + limit = 0 + skip = 0 + update_seq = True + endkey = { 'foo': 'bar' } + endkey_docid = 'testString' + group = True + group_level = 1 + key = { 'foo': 'bar' } + keys = [{ 'foo': 'bar' }] + reduce = True + stable = True + startkey = { 'foo': 'bar' } + startkey_docid = 'testString' + update = 'true' # Pass in all but one required param and check for a ValueError req_param_dict = { @@ -4629,7 +5064,7 @@ def test_post_view_queries_all_params(self): db, ddoc, view, - queries=queries, + queries, headers={} ) @@ -4641,38 +5076,6 @@ def test_post_view_queries_all_params(self): assert req_body['queries'] == [view_query_model] - @responses.activate - def test_post_view_queries_required_params(self): - """ - test_post_view_queries_required_params() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_design/testString/_view/testString/queries') - mock_response = '{"results": [{"total_rows": 0, "update_seq": "update_seq", "rows": [{"caused_by": "caused_by", "error": "error", "reason": "reason", "doc": {"_attachments": {"mapKey": {"content_type": "content_type", "data": "VGhpcyBpcyBhbiBlbmNvZGVkIGJ5dGUgYXJyYXku", "digest": "digest", "encoded_length": 0, "encoding": "encoding", "follows": false, "length": 0, "revpos": 1, "stub": true}}, "_conflicts": ["conflicts"], "_deleted": false, "_deleted_conflicts": ["deleted_conflicts"], "_id": "id", "_local_seq": "local_seq", "_rev": "rev", "_revisions": {"ids": ["ids"], "start": 1}, "_revs_info": [{"rev": "rev", "status": "available"}]}, "id": "id", "key": {"anyKey": "anyValue"}, "value": {"anyKey": "anyValue"}}]}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Set up parameter values - db = 'testString' - ddoc = 'testString' - view = 'testString' - - # Invoke method - response = service.post_view_queries( - db, - ddoc, - view, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - @responses.activate def test_post_view_queries_value_error(self): """ @@ -4687,16 +5090,41 @@ def test_post_view_queries_value_error(self): content_type='application/json', status=200) + # Construct a dict representation of a ViewQuery model + view_query_model = {} + view_query_model['att_encoding_info'] = True + view_query_model['attachments'] = True + view_query_model['conflicts'] = True + view_query_model['descending'] = True + view_query_model['include_docs'] = True + view_query_model['inclusive_end'] = True + view_query_model['limit'] = 0 + view_query_model['skip'] = 0 + view_query_model['update_seq'] = True + view_query_model['endkey'] = { 'foo': 'bar' } + view_query_model['endkey_docid'] = 'testString' + view_query_model['group'] = True + view_query_model['group_level'] = 1 + view_query_model['key'] = { 'foo': 'bar' } + view_query_model['keys'] = [{ 'foo': 'bar' }] + view_query_model['reduce'] = True + view_query_model['stable'] = True + view_query_model['startkey'] = { 'foo': 'bar' } + view_query_model['startkey_docid'] = 'testString' + view_query_model['update'] = 'true' + # Set up parameter values db = 'testString' ddoc = 'testString' view = 'testString' + queries = [view_query_model] # Pass in all but one required param and check for a ValueError req_param_dict = { "db": db, "ddoc": ddoc, "view": view, + "queries": queries, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -4767,7 +5195,7 @@ def test_post_view_queries_as_stream_all_params(self): db, ddoc, view, - queries=queries, + queries, headers={} ) @@ -4785,44 +5213,6 @@ def test_post_view_queries_as_stream_all_params(self): assert str(next(response_buf), "utf-8") == mock_response - @responses.activate - def test_post_view_queries_as_stream_required_params(self): - """ - test_post_view_queries_as_stream_required_params() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_design/testString/_view/testString/queries') - mock_response = '{"foo": "this is a mock response for JSON streaming"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Set up parameter values - db = 'testString' - ddoc = 'testString' - view = 'testString' - - # Invoke method - response = service.post_view_queries_as_stream( - db, - ddoc, - view, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - # Verify streamed JSON response - result = response.get_result() - assert isinstance(result, requests.models.Response) - response_buf = result.iter_content(chunk_size=1024) - assert str(next(response_buf), "utf-8") == mock_response - - @responses.activate def test_post_view_queries_as_stream_value_error(self): """ @@ -4837,16 +5227,41 @@ def test_post_view_queries_as_stream_value_error(self): content_type='application/json', status=200) + # Construct a dict representation of a ViewQuery model + view_query_model = {} + view_query_model['att_encoding_info'] = True + view_query_model['attachments'] = True + view_query_model['conflicts'] = True + view_query_model['descending'] = True + view_query_model['include_docs'] = True + view_query_model['inclusive_end'] = True + view_query_model['limit'] = 0 + view_query_model['skip'] = 0 + view_query_model['update_seq'] = True + view_query_model['endkey'] = { 'foo': 'bar' } + view_query_model['endkey_docid'] = 'testString' + view_query_model['group'] = True + view_query_model['group_level'] = 1 + view_query_model['key'] = { 'foo': 'bar' } + view_query_model['keys'] = [{ 'foo': 'bar' }] + view_query_model['reduce'] = True + view_query_model['stable'] = True + view_query_model['startkey'] = { 'foo': 'bar' } + view_query_model['startkey_docid'] = 'testString' + view_query_model['update'] = 'true' + # Set up parameter values db = 'testString' ddoc = 'testString' view = 'testString' + queries = [view_query_model] # Pass in all but one required param and check for a ValueError req_param_dict = { "db": db, "ddoc": ddoc, "view": view, + "queries": queries, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -5024,36 +5439,6 @@ def test_post_partition_all_docs_all_params(self): assert req_body['startkey'] == 'testString' - @responses.activate - def test_post_partition_all_docs_required_params(self): - """ - test_post_partition_all_docs_required_params() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_partition/testString/_all_docs') - mock_response = '{"total_rows": 0, "rows": [{"caused_by": "caused_by", "error": "error", "reason": "reason", "doc": {"_attachments": {"mapKey": {"content_type": "content_type", "data": "VGhpcyBpcyBhbiBlbmNvZGVkIGJ5dGUgYXJyYXku", "digest": "digest", "encoded_length": 0, "encoding": "encoding", "follows": false, "length": 0, "revpos": 1, "stub": true}}, "_conflicts": ["conflicts"], "_deleted": false, "_deleted_conflicts": ["deleted_conflicts"], "_id": "id", "_local_seq": "local_seq", "_rev": "rev", "_revisions": {"ids": ["ids"], "start": 1}, "_revs_info": [{"rev": "rev", "status": "available"}]}, "id": "id", "key": "key", "value": {"rev": "rev"}}], "update_seq": "update_seq"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Set up parameter values - db = 'testString' - partition_key = 'testString' - - # Invoke method - response = service.post_partition_all_docs( - db, - partition_key, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - @responses.activate def test_post_partition_all_docs_value_error(self): """ @@ -5071,6 +5456,19 @@ def test_post_partition_all_docs_value_error(self): # Set up parameter values db = 'testString' partition_key = 'testString' + att_encoding_info = True + attachments = True + conflicts = True + descending = True + include_docs = True + inclusive_end = True + limit = 0 + skip = 0 + update_seq = True + endkey = 'testString' + key = 'testString' + keys = ['testString'] + startkey = 'testString' # Pass in all but one required param and check for a ValueError req_param_dict = { @@ -5175,42 +5573,6 @@ def test_post_partition_all_docs_as_stream_all_params(self): assert str(next(response_buf), "utf-8") == mock_response - @responses.activate - def test_post_partition_all_docs_as_stream_required_params(self): - """ - test_post_partition_all_docs_as_stream_required_params() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_partition/testString/_all_docs') - mock_response = '{"foo": "this is a mock response for JSON streaming"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Set up parameter values - db = 'testString' - partition_key = 'testString' - - # Invoke method - response = service.post_partition_all_docs_as_stream( - db, - partition_key, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - # Verify streamed JSON response - result = response.get_result() - assert isinstance(result, requests.models.Response) - response_buf = result.iter_content(chunk_size=1024) - assert str(next(response_buf), "utf-8") == mock_response - - @responses.activate def test_post_partition_all_docs_as_stream_value_error(self): """ @@ -5228,6 +5590,19 @@ def test_post_partition_all_docs_as_stream_value_error(self): # Set up parameter values db = 'testString' partition_key = 'testString' + att_encoding_info = True + attachments = True + conflicts = True + descending = True + include_docs = True + inclusive_end = True + limit = 0 + skip = 0 + update_seq = True + endkey = 'testString' + key = 'testString' + keys = ['testString'] + startkey = 'testString' # Pass in all but one required param and check for a ValueError req_param_dict = { @@ -5293,7 +5668,7 @@ def test_post_partition_search_all_params(self): partition_key, ddoc, index, - query=query, + query, bookmark=bookmark, highlight_fields=highlight_fields, highlight_number=highlight_number, @@ -5327,40 +5702,6 @@ def test_post_partition_search_all_params(self): assert req_body['stale'] == 'ok' - @responses.activate - def test_post_partition_search_required_params(self): - """ - test_post_partition_search_required_params() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_partition/testString/_design/testString/_search/testString') - mock_response = '{"total_rows": 0, "bookmark": "bookmark", "by": "by", "counts": {"mapKey": {"mapKey": 0}}, "ranges": {"mapKey": {"mapKey": 0}}, "rows": [{"doc": {"_attachments": {"mapKey": {"content_type": "content_type", "data": "VGhpcyBpcyBhbiBlbmNvZGVkIGJ5dGUgYXJyYXku", "digest": "digest", "encoded_length": 0, "encoding": "encoding", "follows": false, "length": 0, "revpos": 1, "stub": true}}, "_conflicts": ["conflicts"], "_deleted": false, "_deleted_conflicts": ["deleted_conflicts"], "_id": "id", "_local_seq": "local_seq", "_rev": "rev", "_revisions": {"ids": ["ids"], "start": 1}, "_revs_info": [{"rev": "rev", "status": "available"}]}, "fields": {"mapKey": {"anyKey": "anyValue"}}, "highlights": {"mapKey": ["inner"]}, "id": "id"}], "groups": [{"total_rows": 0, "bookmark": "bookmark", "by": "by", "counts": {"mapKey": {"mapKey": 0}}, "ranges": {"mapKey": {"mapKey": 0}}, "rows": [{"doc": {"_attachments": {"mapKey": {"content_type": "content_type", "data": "VGhpcyBpcyBhbiBlbmNvZGVkIGJ5dGUgYXJyYXku", "digest": "digest", "encoded_length": 0, "encoding": "encoding", "follows": false, "length": 0, "revpos": 1, "stub": true}}, "_conflicts": ["conflicts"], "_deleted": false, "_deleted_conflicts": ["deleted_conflicts"], "_id": "id", "_local_seq": "local_seq", "_rev": "rev", "_revisions": {"ids": ["ids"], "start": 1}, "_revs_info": [{"rev": "rev", "status": "available"}]}, "fields": {"mapKey": {"anyKey": "anyValue"}}, "highlights": {"mapKey": ["inner"]}, "id": "id"}]}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Set up parameter values - db = 'testString' - partition_key = 'testString' - ddoc = 'testString' - index = 'testString' - - # Invoke method - response = service.post_partition_search( - db, - partition_key, - ddoc, - index, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - @responses.activate def test_post_partition_search_value_error(self): """ @@ -5380,6 +5721,18 @@ def test_post_partition_search_value_error(self): partition_key = 'testString' ddoc = 'testString' index = 'testString' + query = 'testString' + bookmark = 'testString' + highlight_fields = ['testString'] + highlight_number = 1 + highlight_post_tag = 'testString' + highlight_pre_tag = 'testString' + highlight_size = 1 + include_docs = True + include_fields = ['testString'] + limit = 0 + sort = ['testString'] + stale = 'ok' # Pass in all but one required param and check for a ValueError req_param_dict = { @@ -5387,6 +5740,7 @@ def test_post_partition_search_value_error(self): "partition_key": partition_key, "ddoc": ddoc, "index": index, + "query": query, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -5447,7 +5801,7 @@ def test_post_partition_search_as_stream_all_params(self): partition_key, ddoc, index, - query=query, + query, bookmark=bookmark, highlight_fields=highlight_fields, highlight_number=highlight_number, @@ -5487,46 +5841,6 @@ def test_post_partition_search_as_stream_all_params(self): assert str(next(response_buf), "utf-8") == mock_response - @responses.activate - def test_post_partition_search_as_stream_required_params(self): - """ - test_post_partition_search_as_stream_required_params() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_partition/testString/_design/testString/_search/testString') - mock_response = '{"foo": "this is a mock response for JSON streaming"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Set up parameter values - db = 'testString' - partition_key = 'testString' - ddoc = 'testString' - index = 'testString' - - # Invoke method - response = service.post_partition_search_as_stream( - db, - partition_key, - ddoc, - index, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - # Verify streamed JSON response - result = response.get_result() - assert isinstance(result, requests.models.Response) - response_buf = result.iter_content(chunk_size=1024) - assert str(next(response_buf), "utf-8") == mock_response - - @responses.activate def test_post_partition_search_as_stream_value_error(self): """ @@ -5546,6 +5860,18 @@ def test_post_partition_search_as_stream_value_error(self): partition_key = 'testString' ddoc = 'testString' index = 'testString' + query = 'testString' + bookmark = 'testString' + highlight_fields = ['testString'] + highlight_number = 1 + highlight_post_tag = 'testString' + highlight_pre_tag = 'testString' + highlight_size = 1 + include_docs = True + include_fields = ['testString'] + limit = 3 + sort = ['testString'] + stale = 'ok' # Pass in all but one required param and check for a ValueError req_param_dict = { @@ -5553,6 +5879,7 @@ def test_post_partition_search_as_stream_value_error(self): "partition_key": partition_key, "ddoc": ddoc, "index": index, + "query": query, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -5671,40 +5998,6 @@ def test_post_partition_view_all_params(self): assert req_body['update'] == 'true' - @responses.activate - def test_post_partition_view_required_params(self): - """ - test_post_partition_view_required_params() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_partition/testString/_design/testString/_view/testString') - mock_response = '{"total_rows": 0, "update_seq": "update_seq", "rows": [{"caused_by": "caused_by", "error": "error", "reason": "reason", "doc": {"_attachments": {"mapKey": {"content_type": "content_type", "data": "VGhpcyBpcyBhbiBlbmNvZGVkIGJ5dGUgYXJyYXku", "digest": "digest", "encoded_length": 0, "encoding": "encoding", "follows": false, "length": 0, "revpos": 1, "stub": true}}, "_conflicts": ["conflicts"], "_deleted": false, "_deleted_conflicts": ["deleted_conflicts"], "_id": "id", "_local_seq": "local_seq", "_rev": "rev", "_revisions": {"ids": ["ids"], "start": 1}, "_revs_info": [{"rev": "rev", "status": "available"}]}, "id": "id", "key": {"anyKey": "anyValue"}, "value": {"anyKey": "anyValue"}}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Set up parameter values - db = 'testString' - partition_key = 'testString' - ddoc = 'testString' - view = 'testString' - - # Invoke method - response = service.post_partition_view( - db, - partition_key, - ddoc, - view, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - @responses.activate def test_post_partition_view_value_error(self): """ @@ -5724,6 +6017,26 @@ def test_post_partition_view_value_error(self): partition_key = 'testString' ddoc = 'testString' view = 'testString' + att_encoding_info = True + attachments = True + conflicts = True + descending = True + include_docs = True + inclusive_end = True + limit = 0 + skip = 0 + update_seq = True + endkey = { 'foo': 'bar' } + endkey_docid = 'testString' + group = True + group_level = 1 + key = { 'foo': 'bar' } + keys = [{ 'foo': 'bar' }] + reduce = True + stable = True + startkey = { 'foo': 'bar' } + startkey_docid = 'testString' + update = 'true' # Pass in all but one required param and check for a ValueError req_param_dict = { @@ -5855,46 +6168,6 @@ def test_post_partition_view_as_stream_all_params(self): assert str(next(response_buf), "utf-8") == mock_response - @responses.activate - def test_post_partition_view_as_stream_required_params(self): - """ - test_post_partition_view_as_stream_required_params() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_partition/testString/_design/testString/_view/testString') - mock_response = '{"foo": "this is a mock response for JSON streaming"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Set up parameter values - db = 'testString' - partition_key = 'testString' - ddoc = 'testString' - view = 'testString' - - # Invoke method - response = service.post_partition_view_as_stream( - db, - partition_key, - ddoc, - view, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - # Verify streamed JSON response - result = response.get_result() - assert isinstance(result, requests.models.Response) - response_buf = result.iter_content(chunk_size=1024) - assert str(next(response_buf), "utf-8") == mock_response - - @responses.activate def test_post_partition_view_as_stream_value_error(self): """ @@ -5914,6 +6187,26 @@ def test_post_partition_view_as_stream_value_error(self): partition_key = 'testString' ddoc = 'testString' view = 'testString' + att_encoding_info = True + attachments = True + conflicts = True + descending = True + include_docs = True + inclusive_end = True + limit = 0 + skip = 0 + update_seq = True + endkey = { 'foo': 'bar' } + endkey_docid = 'testString' + group = True + group_level = 1 + key = { 'foo': 'bar' } + keys = [{ 'foo': 'bar' }] + reduce = True + stable = True + startkey = { 'foo': 'bar' } + startkey_docid = 'testString' + update = 'true' # Pass in all but one required param and check for a ValueError req_param_dict = { @@ -5976,7 +6269,7 @@ def test_post_partition_find_all_params(self): response = service.post_partition_find( db, partition_key, - selector=selector, + selector, bookmark=bookmark, conflicts=conflicts, execution_stats=execution_stats, @@ -5994,48 +6287,18 @@ def test_post_partition_find_all_params(self): assert len(responses.calls) == 1 assert response.status_code == 200 # Validate body params - req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) - assert req_body['selector'] == {} - assert req_body['bookmark'] == 'testString' - assert req_body['conflicts'] == True - assert req_body['execution_stats'] == True - assert req_body['fields'] == ['testString'] - assert req_body['limit'] == 0 - assert req_body['skip'] == 0 - assert req_body['sort'] == [{}] - assert req_body['stable'] == True - assert req_body['update'] == 'false' - assert req_body['use_index'] == ['testString'] - - - @responses.activate - def test_post_partition_find_required_params(self): - """ - test_post_partition_find_required_params() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_partition/testString/_find') - mock_response = '{"bookmark": "bookmark", "docs": [{"_attachments": {"mapKey": {"content_type": "content_type", "data": "VGhpcyBpcyBhbiBlbmNvZGVkIGJ5dGUgYXJyYXku", "digest": "digest", "encoded_length": 0, "encoding": "encoding", "follows": false, "length": 0, "revpos": 1, "stub": true}}, "_conflicts": ["conflicts"], "_deleted": false, "_deleted_conflicts": ["deleted_conflicts"], "_id": "id", "_local_seq": "local_seq", "_rev": "rev", "_revisions": {"ids": ["ids"], "start": 1}, "_revs_info": [{"rev": "rev", "status": "available"}]}], "execution_stats": {"execution_time_ms": 17, "results_returned": 0, "total_docs_examined": 0, "total_keys_examined": 0, "total_quorum_docs_examined": 0}, "warning": "warning"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Set up parameter values - db = 'testString' - partition_key = 'testString' - - # Invoke method - response = service.post_partition_find( - db, - partition_key, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['selector'] == {} + assert req_body['bookmark'] == 'testString' + assert req_body['conflicts'] == True + assert req_body['execution_stats'] == True + assert req_body['fields'] == ['testString'] + assert req_body['limit'] == 0 + assert req_body['skip'] == 0 + assert req_body['sort'] == [{}] + assert req_body['stable'] == True + assert req_body['update'] == 'false' + assert req_body['use_index'] == ['testString'] @responses.activate @@ -6055,11 +6318,23 @@ def test_post_partition_find_value_error(self): # Set up parameter values db = 'testString' partition_key = 'testString' + selector = {} + bookmark = 'testString' + conflicts = True + execution_stats = True + fields = ['testString'] + limit = 0 + skip = 0 + sort = [{}] + stable = True + update = 'false' + use_index = ['testString'] # Pass in all but one required param and check for a ValueError req_param_dict = { "db": db, "partition_key": partition_key, + "selector": selector, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -6115,7 +6390,7 @@ def test_post_partition_find_as_stream_all_params(self): response = service.post_partition_find_as_stream( db, partition_key, - selector=selector, + selector, bookmark=bookmark, conflicts=conflicts, execution_stats=execution_stats, @@ -6153,42 +6428,6 @@ def test_post_partition_find_as_stream_all_params(self): assert str(next(response_buf), "utf-8") == mock_response - @responses.activate - def test_post_partition_find_as_stream_required_params(self): - """ - test_post_partition_find_as_stream_required_params() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_partition/testString/_find') - mock_response = '{"foo": "this is a mock response for JSON streaming"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Set up parameter values - db = 'testString' - partition_key = 'testString' - - # Invoke method - response = service.post_partition_find_as_stream( - db, - partition_key, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - # Verify streamed JSON response - result = response.get_result() - assert isinstance(result, requests.models.Response) - response_buf = result.iter_content(chunk_size=1024) - assert str(next(response_buf), "utf-8") == mock_response - - @responses.activate def test_post_partition_find_as_stream_value_error(self): """ @@ -6206,11 +6445,23 @@ def test_post_partition_find_as_stream_value_error(self): # Set up parameter values db = 'testString' partition_key = 'testString' + selector = {} + bookmark = 'testString' + conflicts = True + execution_stats = True + fields = ['testString'] + limit = 0 + skip = 0 + sort = [{}] + stable = True + update = 'false' + use_index = ['testString'] # Pass in all but one required param and check for a ValueError req_param_dict = { "db": db, "partition_key": partition_key, + "selector": selector, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -6275,7 +6526,7 @@ def test_post_explain_all_params(self): # Invoke method response = service.post_explain( db, - selector=selector, + selector, bookmark=bookmark, conflicts=conflicts, execution_stats=execution_stats, @@ -6309,34 +6560,6 @@ def test_post_explain_all_params(self): assert req_body['r'] == 1 - @responses.activate - def test_post_explain_required_params(self): - """ - test_post_explain_required_params() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_explain') - mock_response = '{"dbname": "dbname", "fields": ["fields"], "index": {"ddoc": "ddoc", "def": {"default_analyzer": {"name": "classic", "stopwords": ["stopwords"]}, "default_field": {"analyzer": {"name": "classic", "stopwords": ["stopwords"]}, "enabled": false}, "fields": [{"name": "name", "type": "boolean"}], "index_array_lengths": false}, "name": "name", "type": "json"}, "limit": 0, "opts": {"mapKey": {"anyKey": "anyValue"}}, "range": {"end_key": [{"anyKey": "anyValue"}], "start_key": [{"anyKey": "anyValue"}]}, "selector": {"mapKey": {"anyKey": "anyValue"}}, "skip": 0}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Set up parameter values - db = 'testString' - - # Invoke method - response = service.post_explain( - db, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - @responses.activate def test_post_explain_value_error(self): """ @@ -6353,10 +6576,23 @@ def test_post_explain_value_error(self): # Set up parameter values db = 'testString' + selector = {} + bookmark = 'testString' + conflicts = True + execution_stats = True + fields = ['testString'] + limit = 0 + skip = 0 + sort = [{}] + stable = True + update = 'false' + use_index = ['testString'] + r = 1 # Pass in all but one required param and check for a ValueError req_param_dict = { "db": db, + "selector": selector, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -6411,7 +6647,7 @@ def test_post_find_all_params(self): # Invoke method response = service.post_find( db, - selector=selector, + selector, bookmark=bookmark, conflicts=conflicts, execution_stats=execution_stats, @@ -6445,34 +6681,6 @@ def test_post_find_all_params(self): assert req_body['r'] == 1 - @responses.activate - def test_post_find_required_params(self): - """ - test_post_find_required_params() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_find') - mock_response = '{"bookmark": "bookmark", "docs": [{"_attachments": {"mapKey": {"content_type": "content_type", "data": "VGhpcyBpcyBhbiBlbmNvZGVkIGJ5dGUgYXJyYXku", "digest": "digest", "encoded_length": 0, "encoding": "encoding", "follows": false, "length": 0, "revpos": 1, "stub": true}}, "_conflicts": ["conflicts"], "_deleted": false, "_deleted_conflicts": ["deleted_conflicts"], "_id": "id", "_local_seq": "local_seq", "_rev": "rev", "_revisions": {"ids": ["ids"], "start": 1}, "_revs_info": [{"rev": "rev", "status": "available"}]}], "execution_stats": {"execution_time_ms": 17, "results_returned": 0, "total_docs_examined": 0, "total_keys_examined": 0, "total_quorum_docs_examined": 0}, "warning": "warning"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Set up parameter values - db = 'testString' - - # Invoke method - response = service.post_find( - db, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - @responses.activate def test_post_find_value_error(self): """ @@ -6489,10 +6697,23 @@ def test_post_find_value_error(self): # Set up parameter values db = 'testString' + selector = {} + bookmark = 'testString' + conflicts = True + execution_stats = True + fields = ['testString'] + limit = 0 + skip = 0 + sort = [{}] + stable = True + update = 'false' + use_index = ['testString'] + r = 1 # Pass in all but one required param and check for a ValueError req_param_dict = { "db": db, + "selector": selector, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -6547,7 +6768,7 @@ def test_post_find_as_stream_all_params(self): # Invoke method response = service.post_find_as_stream( db, - selector=selector, + selector, bookmark=bookmark, conflicts=conflicts, execution_stats=execution_stats, @@ -6587,40 +6808,6 @@ def test_post_find_as_stream_all_params(self): assert str(next(response_buf), "utf-8") == mock_response - @responses.activate - def test_post_find_as_stream_required_params(self): - """ - test_post_find_as_stream_required_params() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_find') - mock_response = '{"foo": "this is a mock response for JSON streaming"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Set up parameter values - db = 'testString' - - # Invoke method - response = service.post_find_as_stream( - db, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - # Verify streamed JSON response - result = response.get_result() - assert isinstance(result, requests.models.Response) - response_buf = result.iter_content(chunk_size=1024) - assert str(next(response_buf), "utf-8") == mock_response - - @responses.activate def test_post_find_as_stream_value_error(self): """ @@ -6637,10 +6824,23 @@ def test_post_find_as_stream_value_error(self): # Set up parameter values db = 'testString' + selector = {} + bookmark = 'testString' + conflicts = True + execution_stats = True + fields = ['testString'] + limit = 0 + skip = 0 + sort = [{}] + stable = True + update = 'false' + use_index = ['testString'] + r = 1 # Pass in all but one required param and check for a ValueError req_param_dict = { "db": db, + "selector": selector, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -6772,9 +6972,9 @@ def test_post_index_all_params(self): # Set up parameter values db = 'testString' + index = index_definition_model ddoc = 'testString' def_ = index_definition_model - index = index_definition_model name = 'testString' partial_filter_selector = {} partitioned = True @@ -6783,9 +6983,9 @@ def test_post_index_all_params(self): # Invoke method response = service.post_index( db, + index, ddoc=ddoc, def_=def_, - index=index, name=name, partial_filter_selector=partial_filter_selector, partitioned=partitioned, @@ -6798,9 +6998,9 @@ def test_post_index_all_params(self): assert response.status_code == 200 # Validate body params req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['index'] == index_definition_model assert req_body['ddoc'] == 'testString' assert req_body['def'] == index_definition_model - assert req_body['index'] == index_definition_model assert req_body['name'] == 'testString' assert req_body['partial_filter_selector'] == {} assert req_body['partitioned'] == True @@ -6808,9 +7008,9 @@ def test_post_index_all_params(self): @responses.activate - def test_post_index_required_params(self): + def test_post_index_value_error(self): """ - test_post_index_required_params() + test_post_index_value_error() """ # Set up mock url = self.preprocess_url(base_url + '/testString/_index') @@ -6821,40 +7021,43 @@ def test_post_index_required_params(self): content_type='application/json', status=200) - # Set up parameter values - db = 'testString' - - # Invoke method - response = service.post_index( - db, - headers={} - ) + # Construct a dict representation of a Analyzer model + analyzer_model = {} + analyzer_model['name'] = 'classic' + analyzer_model['stopwords'] = ['testString'] - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 + # Construct a dict representation of a IndexTextOperatorDefaultField model + index_text_operator_default_field_model = {} + index_text_operator_default_field_model['analyzer'] = analyzer_model + index_text_operator_default_field_model['enabled'] = True + # Construct a dict representation of a IndexField model + index_field_model = {} + index_field_model['name'] = 'testString' + index_field_model['type'] = 'boolean' + index_field_model['foo'] = 'asc' - @responses.activate - def test_post_index_value_error(self): - """ - test_post_index_value_error() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_index') - mock_response = '{"id": "id", "name": "name", "result": "created"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + # Construct a dict representation of a IndexDefinition model + index_definition_model = {} + index_definition_model['default_analyzer'] = analyzer_model + index_definition_model['default_field'] = index_text_operator_default_field_model + index_definition_model['fields'] = [index_field_model] + index_definition_model['index_array_lengths'] = True # Set up parameter values db = 'testString' + index = index_definition_model + ddoc = 'testString' + def_ = index_definition_model + name = 'testString' + partial_filter_selector = {} + partitioned = True + type = 'json' # Pass in all but one required param and check for a ValueError req_param_dict = { "db": db, + "index": index, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -6989,8 +7192,8 @@ def test_post_search_analyze_all_params(self): # Invoke method response = service.post_search_analyze( - analyzer=analyzer, - text=text, + analyzer, + text, headers={} ) @@ -7004,9 +7207,9 @@ def test_post_search_analyze_all_params(self): @responses.activate - def test_post_search_analyze_required_params(self): + def test_post_search_analyze_value_error(self): """ - test_post_search_analyze_required_params() + test_post_search_analyze_value_error() """ # Set up mock url = self.preprocess_url(base_url + '/_search_analyze') @@ -7017,13 +7220,20 @@ def test_post_search_analyze_required_params(self): content_type='application/json', status=200) - # Invoke method - response = service.post_search_analyze() + # Set up parameter values + analyzer = 'arabic' + text = 'testString' + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "analyzer": analyzer, + "text": text, + } + for param in req_param_dict.keys(): + req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} + with pytest.raises(ValueError): + service.post_search_analyze(**req_copy) - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 class TestPostSearch(): @@ -7082,7 +7292,7 @@ def test_post_search_all_params(self): db, ddoc, index, - query=query, + query, bookmark=bookmark, highlight_fields=highlight_fields, highlight_number=highlight_number, @@ -7128,38 +7338,6 @@ def test_post_search_all_params(self): assert req_body['ranges'] == {} - @responses.activate - def test_post_search_required_params(self): - """ - test_post_search_required_params() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_design/testString/_search/testString') - mock_response = '{"total_rows": 0, "bookmark": "bookmark", "by": "by", "counts": {"mapKey": {"mapKey": 0}}, "ranges": {"mapKey": {"mapKey": 0}}, "rows": [{"doc": {"_attachments": {"mapKey": {"content_type": "content_type", "data": "VGhpcyBpcyBhbiBlbmNvZGVkIGJ5dGUgYXJyYXku", "digest": "digest", "encoded_length": 0, "encoding": "encoding", "follows": false, "length": 0, "revpos": 1, "stub": true}}, "_conflicts": ["conflicts"], "_deleted": false, "_deleted_conflicts": ["deleted_conflicts"], "_id": "id", "_local_seq": "local_seq", "_rev": "rev", "_revisions": {"ids": ["ids"], "start": 1}, "_revs_info": [{"rev": "rev", "status": "available"}]}, "fields": {"mapKey": {"anyKey": "anyValue"}}, "highlights": {"mapKey": ["inner"]}, "id": "id"}], "groups": [{"total_rows": 0, "bookmark": "bookmark", "by": "by", "counts": {"mapKey": {"mapKey": 0}}, "ranges": {"mapKey": {"mapKey": 0}}, "rows": [{"doc": {"_attachments": {"mapKey": {"content_type": "content_type", "data": "VGhpcyBpcyBhbiBlbmNvZGVkIGJ5dGUgYXJyYXku", "digest": "digest", "encoded_length": 0, "encoding": "encoding", "follows": false, "length": 0, "revpos": 1, "stub": true}}, "_conflicts": ["conflicts"], "_deleted": false, "_deleted_conflicts": ["deleted_conflicts"], "_id": "id", "_local_seq": "local_seq", "_rev": "rev", "_revisions": {"ids": ["ids"], "start": 1}, "_revs_info": [{"rev": "rev", "status": "available"}]}, "fields": {"mapKey": {"anyKey": "anyValue"}}, "highlights": {"mapKey": ["inner"]}, "id": "id"}]}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Set up parameter values - db = 'testString' - ddoc = 'testString' - index = 'testString' - - # Invoke method - response = service.post_search( - db, - ddoc, - index, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - @responses.activate def test_post_search_value_error(self): """ @@ -7178,12 +7356,31 @@ def test_post_search_value_error(self): db = 'testString' ddoc = 'testString' index = 'testString' + query = 'testString' + bookmark = 'testString' + highlight_fields = ['testString'] + highlight_number = 1 + highlight_post_tag = 'testString' + highlight_pre_tag = 'testString' + highlight_size = 1 + include_docs = True + include_fields = ['testString'] + limit = 0 + sort = ['testString'] + stale = 'ok' + counts = ['testString'] + drilldown = [['testString']] + group_field = 'testString' + group_limit = 1 + group_sort = ['testString'] + ranges = {} # Pass in all but one required param and check for a ValueError req_param_dict = { "db": db, "ddoc": ddoc, "index": index, + "query": query, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -7248,7 +7445,7 @@ def test_post_search_as_stream_all_params(self): db, ddoc, index, - query=query, + query, bookmark=bookmark, highlight_fields=highlight_fields, highlight_number=highlight_number, @@ -7300,44 +7497,6 @@ def test_post_search_as_stream_all_params(self): assert str(next(response_buf), "utf-8") == mock_response - @responses.activate - def test_post_search_as_stream_required_params(self): - """ - test_post_search_as_stream_required_params() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_design/testString/_search/testString') - mock_response = '{"foo": "this is a mock response for JSON streaming"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Set up parameter values - db = 'testString' - ddoc = 'testString' - index = 'testString' - - # Invoke method - response = service.post_search_as_stream( - db, - ddoc, - index, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - # Verify streamed JSON response - result = response.get_result() - assert isinstance(result, requests.models.Response) - response_buf = result.iter_content(chunk_size=1024) - assert str(next(response_buf), "utf-8") == mock_response - - @responses.activate def test_post_search_as_stream_value_error(self): """ @@ -7356,12 +7515,31 @@ def test_post_search_as_stream_value_error(self): db = 'testString' ddoc = 'testString' index = 'testString' + query = 'testString' + bookmark = 'testString' + highlight_fields = ['testString'] + highlight_number = 1 + highlight_post_tag = 'testString' + highlight_pre_tag = 'testString' + highlight_size = 1 + include_docs = True + include_fields = ['testString'] + limit = 3 + sort = ['testString'] + stale = 'ok' + counts = ['testString'] + drilldown = [['testString']] + group_field = 'testString' + group_limit = 1 + group_sort = ['testString'] + ranges = {} # Pass in all but one required param and check for a ValueError req_param_dict = { "db": db, "ddoc": ddoc, "index": index, + "query": query, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -8149,62 +8327,176 @@ def test_head_scheduler_job_all_params(self): status=200) # Set up parameter values - job_id = 'testString' + job_id = 'testString' + + # Invoke method + response = service.head_scheduler_job( + job_id, + headers={} + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + + @responses.activate + def test_head_scheduler_job_value_error(self): + """ + test_head_scheduler_job_value_error() + """ + # Set up mock + url = self.preprocess_url(base_url + '/_scheduler/jobs/testString') + responses.add(responses.HEAD, + url, + status=200) + + # Set up parameter values + job_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "job_id": job_id, + } + for param in req_param_dict.keys(): + req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} + with pytest.raises(ValueError): + service.head_scheduler_job(**req_copy) + + + +class TestPostReplicate(): + """ + Test Class for post_replicate + """ + + def preprocess_url(self, request_url: str): + """ + Preprocess the request URL to ensure the mock response will be found. + """ + if re.fullmatch('.*/+', request_url) is None: + return request_url + else: + return re.compile(request_url.rstrip('/') + '/+') + + @responses.activate + def test_post_replicate_all_params(self): + """ + post_replicate() + """ + # Set up mock + url = self.preprocess_url(base_url + '/_replicate') + mock_response = '{"history": [{"doc_write_failures": 0, "docs_read": 0, "docs_written": 0, "end_last_seq": "end_last_seq", "end_time": "end_time", "missing_checked": 0, "missing_found": 0, "recorded_seq": "recorded_seq", "session_id": "session_id", "start_last_seq": "start_last_seq", "start_time": "start_time"}], "ok": true, "replication_id_version": 0, "session_id": "session_id", "source_last_seq": "source_last_seq"}' + responses.add(responses.POST, + url, + body=mock_response, + content_type='application/json', + status=200) + + # Construct a dict representation of a Attachment model + attachment_model = {} + attachment_model['content_type'] = 'testString' + attachment_model['data'] = 'VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=' + attachment_model['digest'] = 'testString' + attachment_model['encoded_length'] = 0 + attachment_model['encoding'] = 'testString' + attachment_model['follows'] = True + attachment_model['length'] = 0 + attachment_model['revpos'] = 1 + attachment_model['stub'] = True + + # Construct a dict representation of a Revisions model + revisions_model = {} + revisions_model['ids'] = ['testString'] + revisions_model['start'] = 1 + + # Construct a dict representation of a DocumentRevisionStatus model + document_revision_status_model = {} + document_revision_status_model['rev'] = 'testString' + document_revision_status_model['status'] = 'available' + + # Construct a dict representation of a ReplicationCreateTargetParameters model + replication_create_target_parameters_model = {} + replication_create_target_parameters_model['n'] = 1 + replication_create_target_parameters_model['partitioned'] = True + replication_create_target_parameters_model['q'] = 1 + + # Construct a dict representation of a ReplicationDatabaseAuthIam model + replication_database_auth_iam_model = {} + replication_database_auth_iam_model['api_key'] = 'testString' + + # Construct a dict representation of a ReplicationDatabaseAuth model + replication_database_auth_model = {} + replication_database_auth_model['iam'] = replication_database_auth_iam_model + + # Construct a dict representation of a ReplicationDatabase model + replication_database_model = {} + replication_database_model['auth'] = replication_database_auth_model + replication_database_model['headers'] = {} + replication_database_model['url'] = 'testString' + + # Construct a dict representation of a UserContext model + user_context_model = {} + user_context_model['db'] = 'testString' + user_context_model['name'] = 'testString' + user_context_model['roles'] = ['_reader'] + + # Construct a dict representation of a ReplicationDocument model + replication_document_model = {} + replication_document_model['_attachments'] = {} + replication_document_model['_conflicts'] = ['testString'] + replication_document_model['_deleted'] = True + replication_document_model['_deleted_conflicts'] = ['testString'] + replication_document_model['_id'] = 'testString' + replication_document_model['_local_seq'] = 'testString' + replication_document_model['_rev'] = 'testString' + replication_document_model['_revisions'] = revisions_model + replication_document_model['_revs_info'] = [document_revision_status_model] + replication_document_model['cancel'] = True + replication_document_model['checkpoint_interval'] = 0 + replication_document_model['connection_timeout'] = 0 + replication_document_model['continuous'] = True + replication_document_model['create_target'] = True + replication_document_model['create_target_params'] = replication_create_target_parameters_model + replication_document_model['doc_ids'] = ['testString'] + replication_document_model['filter'] = 'testString' + replication_document_model['http_connections'] = 1 + replication_document_model['query_params'] = {} + replication_document_model['retries_per_request'] = 0 + replication_document_model['selector'] = {} + replication_document_model['since_seq'] = 'testString' + replication_document_model['socket_options'] = 'testString' + replication_document_model['source'] = replication_database_model + replication_document_model['source_proxy'] = 'testString' + replication_document_model['target'] = replication_database_model + replication_document_model['target_proxy'] = 'testString' + replication_document_model['use_checkpoints'] = True + replication_document_model['user_ctx'] = user_context_model + replication_document_model['worker_batch_size'] = 1 + replication_document_model['worker_processes'] = 1 + replication_document_model['foo'] = { 'foo': 'bar' } + + # Set up parameter values + replication_document = replication_document_model # Invoke method - response = service.head_scheduler_job( - job_id, + response = service.post_replicate( + replication_document, headers={} ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body == replication_document @responses.activate - def test_head_scheduler_job_value_error(self): - """ - test_head_scheduler_job_value_error() - """ - # Set up mock - url = self.preprocess_url(base_url + '/_scheduler/jobs/testString') - responses.add(responses.HEAD, - url, - status=200) - - # Set up parameter values - job_id = 'testString' - - # Pass in all but one required param and check for a ValueError - req_param_dict = { - "job_id": job_id, - } - for param in req_param_dict.keys(): - req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} - with pytest.raises(ValueError): - service.head_scheduler_job(**req_copy) - - - -class TestPostReplicate(): - """ - Test Class for post_replicate - """ - - def preprocess_url(self, request_url: str): - """ - Preprocess the request URL to ensure the mock response will be found. - """ - if re.fullmatch('.*/+', request_url) is None: - return request_url - else: - return re.compile(request_url.rstrip('/') + '/+') - - @responses.activate - def test_post_replicate_all_params(self): + def test_post_replicate_value_error(self): """ - post_replicate() + test_post_replicate_value_error() """ # Set up mock url = self.preprocess_url(base_url + '/_replicate') @@ -8301,41 +8593,15 @@ def test_post_replicate_all_params(self): # Set up parameter values replication_document = replication_document_model - # Invoke method - response = service.post_replicate( - replication_document=replication_document, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - # Validate body params - req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) - assert req_body == replication_document - - - @responses.activate - def test_post_replicate_required_params(self): - """ - test_post_replicate_required_params() - """ - # Set up mock - url = self.preprocess_url(base_url + '/_replicate') - mock_response = '{"history": [{"doc_write_failures": 0, "docs_read": 0, "docs_written": 0, "end_last_seq": "end_last_seq", "end_time": "end_time", "missing_checked": 0, "missing_found": 0, "recorded_seq": "recorded_seq", "session_id": "session_id", "start_last_seq": "start_last_seq", "start_time": "start_time"}], "ok": true, "replication_id_version": 0, "session_id": "session_id", "source_last_seq": "source_last_seq"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Invoke method - response = service.post_replicate() - + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "replication_document": replication_document, + } + for param in req_param_dict.keys(): + req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} + with pytest.raises(ValueError): + service.post_replicate(**req_copy) - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 class TestDeleteReplicationDocument(): @@ -8708,7 +8974,7 @@ def test_put_replication_document_all_params(self): # Invoke method response = service.put_replication_document( doc_id, - replication_document=replication_document, + replication_document, if_match=if_match, batch=batch, new_edits=new_edits, @@ -8744,18 +9010,106 @@ def test_put_replication_document_required_params(self): content_type='application/json', status=201) + # Construct a dict representation of a Attachment model + attachment_model = {} + attachment_model['content_type'] = 'testString' + attachment_model['data'] = 'VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=' + attachment_model['digest'] = 'testString' + attachment_model['encoded_length'] = 0 + attachment_model['encoding'] = 'testString' + attachment_model['follows'] = True + attachment_model['length'] = 0 + attachment_model['revpos'] = 1 + attachment_model['stub'] = True + + # Construct a dict representation of a Revisions model + revisions_model = {} + revisions_model['ids'] = ['testString'] + revisions_model['start'] = 1 + + # Construct a dict representation of a DocumentRevisionStatus model + document_revision_status_model = {} + document_revision_status_model['rev'] = 'testString' + document_revision_status_model['status'] = 'available' + + # Construct a dict representation of a ReplicationCreateTargetParameters model + replication_create_target_parameters_model = {} + replication_create_target_parameters_model['n'] = 1 + replication_create_target_parameters_model['partitioned'] = True + replication_create_target_parameters_model['q'] = 1 + + # Construct a dict representation of a ReplicationDatabaseAuthIam model + replication_database_auth_iam_model = {} + replication_database_auth_iam_model['api_key'] = 'testString' + + # Construct a dict representation of a ReplicationDatabaseAuth model + replication_database_auth_model = {} + replication_database_auth_model['iam'] = replication_database_auth_iam_model + + # Construct a dict representation of a ReplicationDatabase model + replication_database_model = {} + replication_database_model['auth'] = replication_database_auth_model + replication_database_model['headers'] = {} + replication_database_model['url'] = 'http://myserver.example:5984/foo-db' + + # Construct a dict representation of a UserContext model + user_context_model = {} + user_context_model['db'] = 'testString' + user_context_model['name'] = 'john' + user_context_model['roles'] = ['_reader'] + + # Construct a dict representation of a ReplicationDocument model + replication_document_model = {} + replication_document_model['_attachments'] = {} + replication_document_model['_conflicts'] = ['testString'] + replication_document_model['_deleted'] = True + replication_document_model['_deleted_conflicts'] = ['testString'] + replication_document_model['_id'] = 'testString' + replication_document_model['_local_seq'] = 'testString' + replication_document_model['_rev'] = 'testString' + replication_document_model['_revisions'] = revisions_model + replication_document_model['_revs_info'] = [document_revision_status_model] + replication_document_model['cancel'] = False + replication_document_model['checkpoint_interval'] = 4500 + replication_document_model['connection_timeout'] = 15000 + replication_document_model['continuous'] = True + replication_document_model['create_target'] = True + replication_document_model['create_target_params'] = replication_create_target_parameters_model + replication_document_model['doc_ids'] = ['testString'] + replication_document_model['filter'] = 'ddoc/my_filter' + replication_document_model['http_connections'] = 10 + replication_document_model['query_params'] = {} + replication_document_model['retries_per_request'] = 3 + replication_document_model['selector'] = {} + replication_document_model['since_seq'] = '34-g1AAAAGjeJzLYWBgYMlgTmGQT0lKzi9KdU' + replication_document_model['socket_options'] = '[{keepalive, true}, {nodelay, false}]' + replication_document_model['source'] = replication_database_model + replication_document_model['source_proxy'] = 'http://my-source-proxy.example:8888' + replication_document_model['target'] = replication_database_model + replication_document_model['target_proxy'] = 'http://my-target-proxy.example:8888' + replication_document_model['use_checkpoints'] = False + replication_document_model['user_ctx'] = user_context_model + replication_document_model['worker_batch_size'] = 400 + replication_document_model['worker_processes'] = 3 + replication_document_model['foo'] = { 'foo': 'bar' } + # Set up parameter values doc_id = 'testString' + replication_document = replication_document_model # Invoke method response = service.put_replication_document( doc_id, + replication_document, headers={} ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 201 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body == replication_document @responses.activate @@ -8772,12 +9126,97 @@ def test_put_replication_document_value_error(self): content_type='application/json', status=201) + # Construct a dict representation of a Attachment model + attachment_model = {} + attachment_model['content_type'] = 'testString' + attachment_model['data'] = 'VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=' + attachment_model['digest'] = 'testString' + attachment_model['encoded_length'] = 0 + attachment_model['encoding'] = 'testString' + attachment_model['follows'] = True + attachment_model['length'] = 0 + attachment_model['revpos'] = 1 + attachment_model['stub'] = True + + # Construct a dict representation of a Revisions model + revisions_model = {} + revisions_model['ids'] = ['testString'] + revisions_model['start'] = 1 + + # Construct a dict representation of a DocumentRevisionStatus model + document_revision_status_model = {} + document_revision_status_model['rev'] = 'testString' + document_revision_status_model['status'] = 'available' + + # Construct a dict representation of a ReplicationCreateTargetParameters model + replication_create_target_parameters_model = {} + replication_create_target_parameters_model['n'] = 1 + replication_create_target_parameters_model['partitioned'] = True + replication_create_target_parameters_model['q'] = 1 + + # Construct a dict representation of a ReplicationDatabaseAuthIam model + replication_database_auth_iam_model = {} + replication_database_auth_iam_model['api_key'] = 'testString' + + # Construct a dict representation of a ReplicationDatabaseAuth model + replication_database_auth_model = {} + replication_database_auth_model['iam'] = replication_database_auth_iam_model + + # Construct a dict representation of a ReplicationDatabase model + replication_database_model = {} + replication_database_model['auth'] = replication_database_auth_model + replication_database_model['headers'] = {} + replication_database_model['url'] = 'http://myserver.example:5984/foo-db' + + # Construct a dict representation of a UserContext model + user_context_model = {} + user_context_model['db'] = 'testString' + user_context_model['name'] = 'john' + user_context_model['roles'] = ['_reader'] + + # Construct a dict representation of a ReplicationDocument model + replication_document_model = {} + replication_document_model['_attachments'] = {} + replication_document_model['_conflicts'] = ['testString'] + replication_document_model['_deleted'] = True + replication_document_model['_deleted_conflicts'] = ['testString'] + replication_document_model['_id'] = 'testString' + replication_document_model['_local_seq'] = 'testString' + replication_document_model['_rev'] = 'testString' + replication_document_model['_revisions'] = revisions_model + replication_document_model['_revs_info'] = [document_revision_status_model] + replication_document_model['cancel'] = False + replication_document_model['checkpoint_interval'] = 4500 + replication_document_model['connection_timeout'] = 15000 + replication_document_model['continuous'] = True + replication_document_model['create_target'] = True + replication_document_model['create_target_params'] = replication_create_target_parameters_model + replication_document_model['doc_ids'] = ['testString'] + replication_document_model['filter'] = 'ddoc/my_filter' + replication_document_model['http_connections'] = 10 + replication_document_model['query_params'] = {} + replication_document_model['retries_per_request'] = 3 + replication_document_model['selector'] = {} + replication_document_model['since_seq'] = '34-g1AAAAGjeJzLYWBgYMlgTmGQT0lKzi9KdU' + replication_document_model['socket_options'] = '[{keepalive, true}, {nodelay, false}]' + replication_document_model['source'] = replication_database_model + replication_document_model['source_proxy'] = 'http://my-source-proxy.example:8888' + replication_document_model['target'] = replication_database_model + replication_document_model['target_proxy'] = 'http://my-target-proxy.example:8888' + replication_document_model['use_checkpoints'] = False + replication_document_model['user_ctx'] = user_context_model + replication_document_model['worker_batch_size'] = 400 + replication_document_model['worker_processes'] = 3 + replication_document_model['foo'] = { 'foo': 'bar' } + # Set up parameter values doc_id = 'testString' + replication_document = replication_document_model # Pass in all but one required param and check for a ValueError req_param_dict = { "doc_id": doc_id, + "replication_document": replication_document, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -9120,148 +9559,6 @@ def test_get_session_information_all_params(self): assert response.status_code == 200 -class TestDeleteIamSession(): - """ - Test Class for delete_iam_session - """ - - def preprocess_url(self, request_url: str): - """ - Preprocess the request URL to ensure the mock response will be found. - """ - if re.fullmatch('.*/+', request_url) is None: - return request_url - else: - return re.compile(request_url.rstrip('/') + '/+') - - @responses.activate - def test_delete_iam_session_all_params(self): - """ - delete_iam_session() - """ - # Set up mock - url = self.preprocess_url(base_url + '/_iam_session') - mock_response = '{"ok": true}' - responses.add(responses.DELETE, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Invoke method - response = service.delete_iam_session() - - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - -class TestGetIamSessionInformation(): - """ - Test Class for get_iam_session_information - """ - - def preprocess_url(self, request_url: str): - """ - Preprocess the request URL to ensure the mock response will be found. - """ - if re.fullmatch('.*/+', request_url) is None: - return request_url - else: - return re.compile(request_url.rstrip('/') + '/+') - - @responses.activate - def test_get_iam_session_information_all_params(self): - """ - get_iam_session_information() - """ - # Set up mock - url = self.preprocess_url(base_url + '/_iam_session') - mock_response = '{"id": "id", "ok": true, "scope": "scope", "type": "type"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Invoke method - response = service.get_iam_session_information() - - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - -class TestPostIamSession(): - """ - Test Class for post_iam_session - """ - - def preprocess_url(self, request_url: str): - """ - Preprocess the request URL to ensure the mock response will be found. - """ - if re.fullmatch('.*/+', request_url) is None: - return request_url - else: - return re.compile(request_url.rstrip('/') + '/+') - - @responses.activate - def test_post_iam_session_all_params(self): - """ - post_iam_session() - """ - # Set up mock - url = self.preprocess_url(base_url + '/_iam_session') - mock_response = '{"ok": true}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Set up parameter values - access_token = 'testString' - - # Invoke method - response = service.post_iam_session( - access_token=access_token, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - # Validate body params - req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) - assert req_body['access_token'] == 'testString' - - - @responses.activate - def test_post_iam_session_required_params(self): - """ - test_post_iam_session_required_params() - """ - # Set up mock - url = self.preprocess_url(base_url + '/_iam_session') - mock_response = '{"ok": true}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Invoke method - response = service.post_iam_session() - - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - # endregion ############################################################################## # End of Service: Authentication @@ -9403,34 +9700,6 @@ def test_put_security_all_params(self): assert req_body['couchdb_auth_only'] == True - @responses.activate - def test_put_security_required_params(self): - """ - test_put_security_required_params() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_security') - mock_response = '{"ok": true}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Set up parameter values - db = 'testString' - - # Invoke method - response = service.put_security( - db, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - @responses.activate def test_put_security_value_error(self): """ @@ -9445,8 +9714,17 @@ def test_put_security_value_error(self): content_type='application/json', status=200) + # Construct a dict representation of a SecurityObject model + security_object_model = {} + security_object_model['names'] = ['testString'] + security_object_model['roles'] = ['testString'] + # Set up parameter values db = 'testString' + admins = security_object_model + members = security_object_model + cloudant = {} + couchdb_auth_only = True # Pass in all but one required param and check for a ValueError req_param_dict = { @@ -9539,7 +9817,7 @@ def test_put_cloudant_security_configuration_all_params(self): # Invoke method response = service.put_cloudant_security_configuration( db, - cloudant=cloudant, + cloudant, admins=admins, members=members, couchdb_auth_only=couchdb_auth_only, @@ -9557,34 +9835,6 @@ def test_put_cloudant_security_configuration_all_params(self): assert req_body['couchdb_auth_only'] == True - @responses.activate - def test_put_cloudant_security_configuration_required_params(self): - """ - test_put_cloudant_security_configuration_required_params() - """ - # Set up mock - url = self.preprocess_url(base_url + '/_api/v2/db/testString/_security') - mock_response = '{"ok": true}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Set up parameter values - db = 'testString' - - # Invoke method - response = service.put_cloudant_security_configuration( - db, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - @responses.activate def test_put_cloudant_security_configuration_value_error(self): """ @@ -9599,12 +9849,22 @@ def test_put_cloudant_security_configuration_value_error(self): content_type='application/json', status=200) + # Construct a dict representation of a SecurityObject model + security_object_model = {} + security_object_model['names'] = ['testString'] + security_object_model['roles'] = ['testString'] + # Set up parameter values db = 'testString' + cloudant = {} + admins = security_object_model + members = security_object_model + couchdb_auth_only = True # Pass in all but one required param and check for a ValueError req_param_dict = { "db": db, + "cloudant": cloudant, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -9695,7 +9955,7 @@ def test_put_cors_configuration_all_params(self): # Invoke method response = service.put_cors_configuration( - origins=origins, + origins, allow_credentials=allow_credentials, enable_cors=enable_cors, headers={} @@ -9712,9 +9972,9 @@ def test_put_cors_configuration_all_params(self): @responses.activate - def test_put_cors_configuration_required_params(self): + def test_put_cors_configuration_value_error(self): """ - test_put_cors_configuration_required_params() + test_put_cors_configuration_value_error() """ # Set up mock url = self.preprocess_url(base_url + '/_api/v2/user/config/cors') @@ -9725,13 +9985,20 @@ def test_put_cors_configuration_required_params(self): content_type='application/json', status=200) - # Invoke method - response = service.put_cors_configuration() + # Set up parameter values + origins = ['testString'] + allow_credentials = True + enable_cors = True + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "origins": origins, + } + for param in req_param_dict.keys(): + req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} + with pytest.raises(ValueError): + service.put_cors_configuration(**req_copy) - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 # endregion @@ -10547,7 +10814,7 @@ def test_put_local_document_all_params(self): response = service.put_local_document( db, doc_id, - document=document, + document, content_type=content_type, batch=batch, headers={} @@ -10577,20 +10844,58 @@ def test_put_local_document_required_params(self): content_type='application/json', status=201) + # Construct a dict representation of a Attachment model + attachment_model = {} + attachment_model['content_type'] = 'testString' + attachment_model['data'] = 'VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=' + attachment_model['digest'] = 'testString' + attachment_model['encoded_length'] = 0 + attachment_model['encoding'] = 'testString' + attachment_model['follows'] = True + attachment_model['length'] = 0 + attachment_model['revpos'] = 1 + attachment_model['stub'] = True + + # Construct a dict representation of a Revisions model + revisions_model = {} + revisions_model['ids'] = ['testString'] + revisions_model['start'] = 1 + + # Construct a dict representation of a DocumentRevisionStatus model + document_revision_status_model = {} + document_revision_status_model['rev'] = 'testString' + document_revision_status_model['status'] = 'available' + + # Construct a dict representation of a Document model + document_model = {} + document_model['_attachments'] = {} + document_model['_conflicts'] = ['testString'] + document_model['_deleted'] = True + document_model['_deleted_conflicts'] = ['testString'] + document_model['_id'] = 'testString' + document_model['_local_seq'] = 'testString' + document_model['_rev'] = 'testString' + document_model['_revisions'] = revisions_model + document_model['_revs_info'] = [document_revision_status_model] + document_model['foo'] = { 'foo': 'bar' } + # Set up parameter values db = 'testString' doc_id = 'testString' + document = document_model # Invoke method response = service.put_local_document( db, doc_id, + document, headers={} ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 201 + # Validate body params @responses.activate @@ -10607,14 +10912,51 @@ def test_put_local_document_value_error(self): content_type='application/json', status=201) + # Construct a dict representation of a Attachment model + attachment_model = {} + attachment_model['content_type'] = 'testString' + attachment_model['data'] = 'VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=' + attachment_model['digest'] = 'testString' + attachment_model['encoded_length'] = 0 + attachment_model['encoding'] = 'testString' + attachment_model['follows'] = True + attachment_model['length'] = 0 + attachment_model['revpos'] = 1 + attachment_model['stub'] = True + + # Construct a dict representation of a Revisions model + revisions_model = {} + revisions_model['ids'] = ['testString'] + revisions_model['start'] = 1 + + # Construct a dict representation of a DocumentRevisionStatus model + document_revision_status_model = {} + document_revision_status_model['rev'] = 'testString' + document_revision_status_model['status'] = 'available' + + # Construct a dict representation of a Document model + document_model = {} + document_model['_attachments'] = {} + document_model['_conflicts'] = ['testString'] + document_model['_deleted'] = True + document_model['_deleted_conflicts'] = ['testString'] + document_model['_id'] = 'testString' + document_model['_local_seq'] = 'testString' + document_model['_rev'] = 'testString' + document_model['_revisions'] = revisions_model + document_model['_revs_info'] = [document_revision_status_model] + document_model['foo'] = { 'foo': 'bar' } + # Set up parameter values db = 'testString' doc_id = 'testString' + document = document_model # Pass in all but one required param and check for a ValueError req_param_dict = { "db": db, "doc_id": doc_id, + "document": document, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -10653,7 +10995,6 @@ def test_post_local_docs_all_params(self): # Set up parameter values db = 'testString' - accept = 'application/json' att_encoding_info = True attachments = True conflicts = True @@ -10667,11 +11008,11 @@ def test_post_local_docs_all_params(self): key = 'testString' keys = ['testString'] startkey = 'testString' + accept = 'application/json' # Invoke method response = service.post_local_docs( db, - accept=accept, att_encoding_info=att_encoding_info, attachments=attachments, conflicts=conflicts, @@ -10685,6 +11026,7 @@ def test_post_local_docs_all_params(self): key=key, keys=keys, startkey=startkey, + accept=accept, headers={} ) @@ -10724,16 +11066,57 @@ def test_post_local_docs_required_params(self): # Set up parameter values db = 'testString' + att_encoding_info = True + attachments = True + conflicts = True + descending = True + include_docs = True + inclusive_end = True + limit = 0 + skip = 0 + update_seq = True + endkey = 'testString' + key = 'testString' + keys = ['testString'] + startkey = 'testString' # Invoke method response = service.post_local_docs( db, + att_encoding_info=att_encoding_info, + attachments=attachments, + conflicts=conflicts, + descending=descending, + include_docs=include_docs, + inclusive_end=inclusive_end, + limit=limit, + skip=skip, + update_seq=update_seq, + endkey=endkey, + key=key, + keys=keys, + startkey=startkey, headers={} ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['att_encoding_info'] == True + assert req_body['attachments'] == True + assert req_body['conflicts'] == True + assert req_body['descending'] == True + assert req_body['include_docs'] == True + assert req_body['inclusive_end'] == True + assert req_body['limit'] == 0 + assert req_body['skip'] == 0 + assert req_body['update_seq'] == True + assert req_body['endkey'] == 'testString' + assert req_body['key'] == 'testString' + assert req_body['keys'] == ['testString'] + assert req_body['startkey'] == 'testString' @responses.activate @@ -10752,6 +11135,19 @@ def test_post_local_docs_value_error(self): # Set up parameter values db = 'testString' + att_encoding_info = True + attachments = True + conflicts = True + descending = True + include_docs = True + inclusive_end = True + limit = 0 + skip = 0 + update_seq = True + endkey = 'testString' + key = 'testString' + keys = ['testString'] + startkey = 'testString' # Pass in all but one required param and check for a ValueError req_param_dict = { @@ -10810,14 +11206,14 @@ def test_post_local_docs_queries_all_params(self): # Set up parameter values db = 'testString' - accept = 'application/json' queries = [all_docs_query_model] + accept = 'application/json' # Invoke method response = service.post_local_docs_queries( db, + queries, accept=accept, - queries=queries, headers={} ) @@ -10843,18 +11239,39 @@ def test_post_local_docs_queries_required_params(self): content_type='application/json', status=200) + # Construct a dict representation of a AllDocsQuery model + all_docs_query_model = {} + all_docs_query_model['att_encoding_info'] = True + all_docs_query_model['attachments'] = True + all_docs_query_model['conflicts'] = True + all_docs_query_model['descending'] = True + all_docs_query_model['include_docs'] = True + all_docs_query_model['inclusive_end'] = True + all_docs_query_model['limit'] = 0 + all_docs_query_model['skip'] = 0 + all_docs_query_model['update_seq'] = True + all_docs_query_model['endkey'] = 'testString' + all_docs_query_model['key'] = 'testString' + all_docs_query_model['keys'] = ['testString'] + all_docs_query_model['startkey'] = 'testString' + # Set up parameter values db = 'testString' + queries = [all_docs_query_model] # Invoke method response = service.post_local_docs_queries( db, + queries, headers={} ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['queries'] == [all_docs_query_model] @responses.activate @@ -10871,12 +11288,30 @@ def test_post_local_docs_queries_value_error(self): content_type='application/json', status=200) + # Construct a dict representation of a AllDocsQuery model + all_docs_query_model = {} + all_docs_query_model['att_encoding_info'] = True + all_docs_query_model['attachments'] = True + all_docs_query_model['conflicts'] = True + all_docs_query_model['descending'] = True + all_docs_query_model['include_docs'] = True + all_docs_query_model['inclusive_end'] = True + all_docs_query_model['limit'] = 0 + all_docs_query_model['skip'] = 0 + all_docs_query_model['update_seq'] = True + all_docs_query_model['endkey'] = 'testString' + all_docs_query_model['key'] = 'testString' + all_docs_query_model['keys'] = ['testString'] + all_docs_query_model['startkey'] = 'testString' + # Set up parameter values db = 'testString' + queries = [all_docs_query_model] # Pass in all but one required param and check for a ValueError req_param_dict = { "db": db, + "queries": queries, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -10895,76 +11330,6 @@ def test_post_local_docs_queries_value_error(self): ############################################################################## # region -class TestPostEnsureFullCommit(): - """ - Test Class for post_ensure_full_commit - """ - - def preprocess_url(self, request_url: str): - """ - Preprocess the request URL to ensure the mock response will be found. - """ - if re.fullmatch('.*/+', request_url) is None: - return request_url - else: - return re.compile(request_url.rstrip('/') + '/+') - - @responses.activate - def test_post_ensure_full_commit_all_params(self): - """ - post_ensure_full_commit() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_ensure_full_commit') - mock_response = '{"instance_start_time": "instance_start_time", "ok": true}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) - - # Set up parameter values - db = 'testString' - - # Invoke method - response = service.post_ensure_full_commit( - db, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 201 - - - @responses.activate - def test_post_ensure_full_commit_value_error(self): - """ - test_post_ensure_full_commit_value_error() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_ensure_full_commit') - mock_response = '{"instance_start_time": "instance_start_time", "ok": true}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) - - # Set up parameter values - db = 'testString' - - # Pass in all but one required param and check for a ValueError - req_param_dict = { - "db": db, - } - for param in req_param_dict.keys(): - req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} - with pytest.raises(ValueError): - service.post_ensure_full_commit(**req_copy) - - - class TestPostMissingRevs(): """ Test Class for post_missing_revs @@ -11000,7 +11365,7 @@ def test_post_missing_revs_all_params(self): # Invoke method response = service.post_missing_revs( db, - document_revisions=document_revisions, + document_revisions, headers={} ) @@ -11012,34 +11377,6 @@ def test_post_missing_revs_all_params(self): assert req_body == document_revisions - @responses.activate - def test_post_missing_revs_required_params(self): - """ - test_post_missing_revs_required_params() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_missing_revs') - mock_response = '{"missing_revs": {"mapKey": ["inner"]}}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Set up parameter values - db = 'testString' - - # Invoke method - response = service.post_missing_revs( - db, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - @responses.activate def test_post_missing_revs_value_error(self): """ @@ -11056,10 +11393,12 @@ def test_post_missing_revs_value_error(self): # Set up parameter values db = 'testString' + document_revisions = {} # Pass in all but one required param and check for a ValueError req_param_dict = { "db": db, + "document_revisions": document_revisions, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -11103,7 +11442,7 @@ def test_post_revs_diff_all_params(self): # Invoke method response = service.post_revs_diff( db, - document_revisions=document_revisions, + document_revisions, headers={} ) @@ -11115,34 +11454,6 @@ def test_post_revs_diff_all_params(self): assert req_body == document_revisions - @responses.activate - def test_post_revs_diff_required_params(self): - """ - test_post_revs_diff_required_params() - """ - # Set up mock - url = self.preprocess_url(base_url + '/testString/_revs_diff') - mock_response = '{"mapKey": {"missing": ["missing"], "possible_ancestors": ["possible_ancestors"]}}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) - - # Set up parameter values - db = 'testString' - - # Invoke method - response = service.post_revs_diff( - db, - headers={} - ) - - # Check for correct operation - assert len(responses.calls) == 1 - assert response.status_code == 200 - - @responses.activate def test_post_revs_diff_value_error(self): """ @@ -11159,10 +11470,12 @@ def test_post_revs_diff_value_error(self): # Set up parameter values db = 'testString' + document_revisions = {} # Pass in all but one required param and check for a ValueError req_param_dict = { "db": db, + "document_revisions": document_revisions, } for param in req_param_dict.keys(): req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} @@ -13009,36 +13322,6 @@ def test_document_shard_info_serialization(self): document_shard_info_model_json2 = document_shard_info_model.to_dict() assert document_shard_info_model_json2 == document_shard_info_model_json -class TestEnsureFullCommitInformation(): - """ - Test Class for EnsureFullCommitInformation - """ - - def test_ensure_full_commit_information_serialization(self): - """ - Test serialization/deserialization for EnsureFullCommitInformation - """ - - # Construct a json representation of a EnsureFullCommitInformation model - ensure_full_commit_information_model_json = {} - ensure_full_commit_information_model_json['instance_start_time'] = 'testString' - ensure_full_commit_information_model_json['ok'] = True - - # Construct a model instance of EnsureFullCommitInformation by calling from_dict on the json representation - ensure_full_commit_information_model = EnsureFullCommitInformation.from_dict(ensure_full_commit_information_model_json) - assert ensure_full_commit_information_model != False - - # Construct a model instance of EnsureFullCommitInformation by calling from_dict on the json representation - ensure_full_commit_information_model_dict = EnsureFullCommitInformation.from_dict(ensure_full_commit_information_model_json).__dict__ - ensure_full_commit_information_model2 = EnsureFullCommitInformation(**ensure_full_commit_information_model_dict) - - # Verify the model instances are equivalent - assert ensure_full_commit_information_model == ensure_full_commit_information_model2 - - # Convert model instance back to dict and verify no loss of data - ensure_full_commit_information_model_json2 = ensure_full_commit_information_model.to_dict() - assert ensure_full_commit_information_model_json2 == ensure_full_commit_information_model_json - class TestExecutionStats(): """ Test Class for ExecutionStats @@ -13535,38 +13818,6 @@ def test_geo_result_row_serialization(self): geo_result_row_model_json2 = geo_result_row_model.to_dict() assert geo_result_row_model_json2 == geo_result_row_model_json -class TestIamSessionInformation(): - """ - Test Class for IamSessionInformation - """ - - def test_iam_session_information_serialization(self): - """ - Test serialization/deserialization for IamSessionInformation - """ - - # Construct a json representation of a IamSessionInformation model - iam_session_information_model_json = {} - iam_session_information_model_json['id'] = 'testString' - iam_session_information_model_json['ok'] = True - iam_session_information_model_json['scope'] = 'testString' - iam_session_information_model_json['type'] = 'testString' - - # Construct a model instance of IamSessionInformation by calling from_dict on the json representation - iam_session_information_model = IamSessionInformation.from_dict(iam_session_information_model_json) - assert iam_session_information_model != False - - # Construct a model instance of IamSessionInformation by calling from_dict on the json representation - iam_session_information_model_dict = IamSessionInformation.from_dict(iam_session_information_model_json).__dict__ - iam_session_information_model2 = IamSessionInformation(**iam_session_information_model_dict) - - # Verify the model instances are equivalent - assert iam_session_information_model == iam_session_information_model2 - - # Convert model instance back to dict and verify no loss of data - iam_session_information_model_json2 = iam_session_information_model.to_dict() - assert iam_session_information_model_json2 == iam_session_information_model_json - class TestIndexDefinition(): """ Test Class for IndexDefinition