From 02f47b6514ac2bb80de98316fd29f1faaa612189 Mon Sep 17 00:00:00 2001 From: Mamoon Raja Date: Tue, 31 Mar 2020 16:20:38 -0400 Subject: [PATCH 01/10] docs: update instructions on where to ask questions --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- .github/ISSUE_TEMPLATE/feature_request.md | 2 +- CONTRIBUTING.md | 3 +-- README.md | 4 ++++ 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index f99646058..a6d58b0b9 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,7 +7,7 @@ assignees: '' --- -Remember, an issue is not the place to ask questions. You can use [Stack Overflow](http://stackoverflow.com/questions/tagged/ibm-watson) for that, or you may want to start a discussion on the [dW Answers](https://developer.ibm.com/answers/questions/ask/?topics=watson). +Remember, an issue is not the place to ask questions. If you have issues with the APIs or have a question about the Watson services, see [Stack Overflow](https://stackoverflow.com/questions/tagged/ibm-watson+python). Before you open an issue, please check if a similar issue already exists or has been closed before. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index c86f075d1..d326a686d 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -7,7 +7,7 @@ assignees: '' --- -Remember, an issue is not the place to ask questions. You can use [Stack Overflow](http://stackoverflow.com/questions/tagged/ibm-watson) for that, or you may want to start a discussion on the [dW Answers](https://developer.ibm.com/answers/questions/ask/?topics=watson). +Remember, an issue is not the place to ask questions. If you have issues with the APIs or have a question about the Watson services, see [Stack Overflow](https://stackoverflow.com/questions/tagged/ibm-watson+python). Before you open an issue, please check if a similar issue already exists or has been closed before. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3ac3a86ae..f46847fe0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,8 +2,7 @@ ## Questions -If you are having difficulties using the APIs or have a question about the IBM Watson Services, -please ask a question on [dW Answers][dw] or [Stack Overflow][stackoverflow]. +If you have issues with the APIs or have a question about the Watson services, see [Stack Overflow](https://stackoverflow.com/questions/tagged/ibm-watson+python). ## Issues diff --git a/README.md b/README.md index 16b4120fc..83c75e46e 100755 --- a/README.md +++ b/README.md @@ -225,6 +225,10 @@ discovery.set_service_url('') Tested on Python 3.5, 3.6, and 3.7. +## Questions + +If you have issues with the APIs or have a question about the Watson services, see [Stack Overflow](https://stackoverflow.com/questions/tagged/ibm-watson+python). + ## Changes for v1.0 Version 1.0 focuses on the move to programmatically-generated code for many of the services. See the [changelog](https://github.com/watson-developer-cloud/python-sdk/wiki/Changelog) for the details. From 230878a256d375c92cef0647e2f5efa51b8a5cf0 Mon Sep 17 00:00:00 2001 From: Mamoon Raja Date: Thu, 16 Apr 2020 10:03:13 -0400 Subject: [PATCH 02/10] feat(LanguageTranslator): add support for auto correct --- ibm_watson/language_translator_v3.py | 89 +++++++++++++++++++++++----- 1 file changed, 75 insertions(+), 14 deletions(-) diff --git a/ibm_watson/language_translator_v3.py b/ibm_watson/language_translator_v3.py index 047af98cb..7e98d4908 100644 --- a/ibm_watson/language_translator_v3.py +++ b/ibm_watson/language_translator_v3.py @@ -93,14 +93,21 @@ def translate(self, """ Translate. - Translates the input text from the source language to the target language. + Translates the input text from the source language to the target language. A + target language or translation model ID is required. The service attempts to + detect the language of the source text if it is not specified. :param List[str] text: Input text in UTF-8 encoding. Multiple entries will result in multiple translations in the response. - :param str model_id: (optional) A globally unique string that identifies - the underlying model that is used for translation. - :param str source: (optional) Translation source language code. - :param str target: (optional) Translation target language code. + :param str model_id: (optional) The model to use for translation. For + example, `en-de` selects the IBM provided base model for English to German + translation. A model ID overrides the source and target parameters and is + required if you use a custom model. If no model ID is specified, you must + specify a target language. + :param str source: (optional) Language code that specifies the language of + the source document. + :param str target: (optional) Language code that specifies the target + language for translation. Required if model ID is not specified. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse @@ -469,16 +476,19 @@ def translate_document(self, :param TextIO file: The contents of the source file to translate. [Supported file - types](https://cloud.ibm.com/docs/services/language-translator?topic=language-translator-document-translator-tutorial#supported-file-formats) + types](https://cloud.ibm.com/docs/language-translator?topic=language-translator-document-translator-tutorial#supported-file-formats) Maximum file size: **20 MB**. :param str filename: (optional) The filename for file. :param str file_content_type: (optional) The content type of file. - :param str model_id: (optional) The model to use for translation. - `model_id` or both `source` and `target` are required. + :param str model_id: (optional) The model to use for translation. For + example, `en-de` selects the IBM provided base model for English to German + translation. A model ID overrides the source and target parameters and is + required if you use a custom model. If no model ID is specified, you must + specify a target language. :param str source: (optional) Language code that specifies the language of the source document. :param str target: (optional) Language code that specifies the target - language for translation. + language for translation. Required if model ID is not specified. :param str document_id: (optional) To use a previously submitted document as the source for a new translation, enter the `document_id` of the document. @@ -879,6 +889,10 @@ class DocumentStatus(): customize the model. If the model is not a custom model, this will be absent or an empty string. :attr str source: Translation source language code. + :attr float detected_language_confidence: (optional) A score between 0 and 1 + indicating the confidence of source language detection. A higher value indicates + greater confidence. This is returned only when the service automatically detects + the source language. :attr str target: Translation target language code. :attr datetime created: The time when the document was submitted. :attr datetime completed: (optional) The time when the translation completed. @@ -898,6 +912,7 @@ def __init__(self, created: datetime, *, base_model_id: str = None, + detected_language_confidence: float = None, completed: datetime = None, word_count: int = None, character_count: int = None) -> None: @@ -918,6 +933,10 @@ def __init__(self, :param str base_model_id: (optional) Model ID of the base model that was used to customize the model. If the model is not a custom model, this will be absent or an empty string. + :param float detected_language_confidence: (optional) A score between 0 and + 1 indicating the confidence of source language detection. A higher value + indicates greater confidence. This is returned only when the service + automatically detects the source language. :param datetime completed: (optional) The time when the translation completed. :param int word_count: (optional) An estimate of the number of words in the @@ -931,6 +950,7 @@ def __init__(self, self.model_id = model_id self.base_model_id = base_model_id self.source = source + self.detected_language_confidence = detected_language_confidence self.target = target self.created = created self.completed = completed @@ -943,8 +963,8 @@ def from_dict(cls, _dict: Dict) -> 'DocumentStatus': args = {} valid_keys = [ 'document_id', 'filename', 'status', 'model_id', 'base_model_id', - 'source', 'target', 'created', 'completed', 'word_count', - 'character_count' + 'source', 'detected_language_confidence', 'target', 'created', + 'completed', 'word_count', 'character_count' ] bad_keys = set(_dict.keys()) - set(valid_keys) if bad_keys: @@ -983,6 +1003,9 @@ def from_dict(cls, _dict: Dict) -> 'DocumentStatus': raise ValueError( 'Required property \'source\' not present in DocumentStatus JSON' ) + if 'detected_language_confidence' in _dict: + args['detected_language_confidence'] = _dict.get( + 'detected_language_confidence') if 'target' in _dict: args['target'] = _dict.get('target') else: @@ -1023,6 +1046,10 @@ def to_dict(self) -> Dict: _dict['base_model_id'] = self.base_model_id if hasattr(self, 'source') and self.source is not None: _dict['source'] = self.source + if hasattr(self, 'detected_language_confidence' + ) and self.detected_language_confidence is not None: + _dict[ + 'detected_language_confidence'] = self.detected_language_confidence if hasattr(self, 'target') and self.target is not None: _dict['target'] = self.target if hasattr(self, 'created') and self.created is not None: @@ -1663,12 +1690,23 @@ class TranslationResult(): :attr int word_count: An estimate of the number of words in the input text. :attr int character_count: Number of characters in the input text. + :attr str detected_language: (optional) The language code of the source text if + the source language was automatically detected. + :attr float detected_language_confidence: (optional) A score between 0 and 1 + indicating the confidence of source language detection. A higher value indicates + greater confidence. This is returned only when the service automatically detects + the source language. :attr List[Translation] translations: List of translation output in UTF-8, corresponding to the input text entries. """ - def __init__(self, word_count: int, character_count: int, - translations: List['Translation']) -> None: + def __init__(self, + word_count: int, + character_count: int, + translations: List['Translation'], + *, + detected_language: str = None, + detected_language_confidence: float = None) -> None: """ Initialize a TranslationResult object. @@ -1677,16 +1715,27 @@ def __init__(self, word_count: int, character_count: int, :param int character_count: Number of characters in the input text. :param List[Translation] translations: List of translation output in UTF-8, corresponding to the input text entries. + :param str detected_language: (optional) The language code of the source + text if the source language was automatically detected. + :param float detected_language_confidence: (optional) A score between 0 and + 1 indicating the confidence of source language detection. A higher value + indicates greater confidence. This is returned only when the service + automatically detects the source language. """ self.word_count = word_count self.character_count = character_count + self.detected_language = detected_language + self.detected_language_confidence = detected_language_confidence self.translations = translations @classmethod def from_dict(cls, _dict: Dict) -> 'TranslationResult': """Initialize a TranslationResult object from a json dictionary.""" args = {} - valid_keys = ['word_count', 'character_count', 'translations'] + valid_keys = [ + 'word_count', 'character_count', 'detected_language', + 'detected_language_confidence', 'translations' + ] bad_keys = set(_dict.keys()) - set(valid_keys) if bad_keys: raise ValueError( @@ -1704,6 +1753,11 @@ def from_dict(cls, _dict: Dict) -> 'TranslationResult': raise ValueError( 'Required property \'character_count\' not present in TranslationResult JSON' ) + if 'detected_language' in _dict: + args['detected_language'] = _dict.get('detected_language') + if 'detected_language_confidence' in _dict: + args['detected_language_confidence'] = _dict.get( + 'detected_language_confidence') if 'translations' in _dict: args['translations'] = [ Translation._from_dict(x) for x in (_dict.get('translations')) @@ -1727,6 +1781,13 @@ def to_dict(self) -> Dict: if hasattr(self, 'character_count') and self.character_count is not None: _dict['character_count'] = self.character_count + if hasattr(self, + 'detected_language') and self.detected_language is not None: + _dict['detected_language'] = self.detected_language + if hasattr(self, 'detected_language_confidence' + ) and self.detected_language_confidence is not None: + _dict[ + 'detected_language_confidence'] = self.detected_language_confidence if hasattr(self, 'translations') and self.translations is not None: _dict['translations'] = [x._to_dict() for x in self.translations] return _dict From 9aa13e94558c37ca815d61ff36d0988943c55bf7 Mon Sep 17 00:00:00 2001 From: Mamoon Raja Date: Thu, 16 Apr 2020 10:04:17 -0400 Subject: [PATCH 03/10] feat(SpeechToText): add support for speech_detector_sensitivity and background_audio_suppression in --- ibm_watson/speech_to_text_v1.py | 206 +++++++++++++++++------- ibm_watson/speech_to_text_v1_adapter.py | 82 +++++++--- 2 files changed, 209 insertions(+), 79 deletions(-) diff --git a/ibm_watson/speech_to_text_v1.py b/ibm_watson/speech_to_text_v1.py index 50c30446e..e23fa4e1a 100644 --- a/ibm_watson/speech_to_text_v1.py +++ b/ibm_watson/speech_to_text_v1.py @@ -29,9 +29,9 @@ customization to adapt a base model for the acoustic characteristics of your audio. For language model customization, the service also supports grammars. A grammar is a formal language specification that lets you restrict the phrases that the service can recognize. -Language model customization is generally available for production use with most supported -languages. Acoustic model customization is beta functionality that is available for all -supported languages. +Language model customization and acoustic model customization are generally available for +production use with all language models that are generally available. Grammars are beta +functionality for all language models that support language model customization. """ import json @@ -172,6 +172,8 @@ def recognize(self, audio_metrics: bool = None, end_of_phrase_silence_time: float = None, split_transcript_at_phrase_end: bool = None, + speech_detector_sensitivity: float = None, + background_audio_suppression: float = None, **kwargs) -> 'DetailedResponse': """ Recognize audio. @@ -302,8 +304,13 @@ def recognize(self, in the audio. Each keyword string can include one or more string tokens. Keywords are spotted only in the final results, not in interim hypotheses. If you specify any keywords, you must also specify a keywords threshold. - You can spot a maximum of 1000 keywords. Omit the parameter or specify an - empty array if you do not need to spot keywords. See [Keyword + Omit the parameter or specify an empty array if you do not need to spot + keywords. + You can spot a maximum of 1000 keywords with a single request. A single + keyword can have a maximum length of 1024 characters, though the maximum + effective length for double-byte languages might be shorter. Keywords are + case-insensitive. + See [Keyword spotting](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#keyword_spotting). :param float keywords_threshold: (optional) A confidence value that is the lower bound for spotting a keyword. A word is considered to match a keyword @@ -351,11 +358,11 @@ def recognize(self, multi-person exchange. By default, the service returns no speaker labels. Setting `speaker_labels` to `true` forces the `timestamps` parameter to be `true`, regardless of whether you specify `false` for the parameter. - **Note:** Applies to US English, Japanese, and Spanish (both broadband and - narrowband models) and UK English (narrowband model) transcription only. To - determine whether a language model supports speaker labels, you can also - use the **Get a model** method and check that the attribute - `speaker_labels` is set to `true`. + **Note:** Applies to US English, German, Japanese, Korean, and Spanish + (both broadband and narrowband models) and UK English (narrowband model) + transcription only. To determine whether a language model supports speaker + labels, you can also use the **Get a model** method and check that the + attribute `speaker_labels` is set to `true`. See [Speaker labels](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#speaker_labels). :param str customization_id: (optional) **Deprecated.** Use the @@ -414,6 +421,30 @@ def recognize(self, transcripts based solely on the pause interval. See [Split transcript at phrase end](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#split_transcript). + :param float speech_detector_sensitivity: (optional) The sensitivity of + speech activity detection that the service is to perform. Use the parameter + to suppress word insertions from music, coughing, and other non-speech + events. The service biases the audio it passes for speech recognition by + evaluating the input audio against prior models of speech and non-speech + activity. + Specify a value between 0.0 and 1.0: + * 0.0 suppresses all audio (no speech is transcribed). + * 0.5 (the default) provides a reasonable compromise for the level of + sensitivity. + * 1.0 suppresses no audio (speech detection sensitivity is disabled). + The values increase on a monotonic curve. See [Speech Activity + Detection](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#detection). + :param float background_audio_suppression: (optional) The level to which + the service is to suppress background audio based on its volume to prevent + it from being transcribed as speech. Use the parameter to suppress side + conversations or background noise. + Specify a value in the range of 0.0 to 1.0: + * 0.0 (the default) provides no suppression (background audio suppression + is disabled). + * 0.5 provides a reasonable level of audio suppression for general usage. + * 1.0 suppresses all audio (no audio is transcribed). + The values increase on a monotonic curve. See [Speech Activity + Detection](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#detection). :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse @@ -451,7 +482,9 @@ def recognize(self, 'redaction': redaction, 'audio_metrics': audio_metrics, 'end_of_phrase_silence_time': end_of_phrase_silence_time, - 'split_transcript_at_phrase_end': split_transcript_at_phrase_end + 'split_transcript_at_phrase_end': split_transcript_at_phrase_end, + 'speech_detector_sensitivity': speech_detector_sensitivity, + 'background_audio_suppression': background_audio_suppression } data = audio @@ -616,6 +649,8 @@ def create_job(self, audio_metrics: bool = None, end_of_phrase_silence_time: float = None, split_transcript_at_phrase_end: bool = None, + speech_detector_sensitivity: float = None, + background_audio_suppression: float = None, **kwargs) -> 'DetailedResponse': """ Create a job. @@ -795,8 +830,13 @@ def create_job(self, in the audio. Each keyword string can include one or more string tokens. Keywords are spotted only in the final results, not in interim hypotheses. If you specify any keywords, you must also specify a keywords threshold. - You can spot a maximum of 1000 keywords. Omit the parameter or specify an - empty array if you do not need to spot keywords. See [Keyword + Omit the parameter or specify an empty array if you do not need to spot + keywords. + You can spot a maximum of 1000 keywords with a single request. A single + keyword can have a maximum length of 1024 characters, though the maximum + effective length for double-byte languages might be shorter. Keywords are + case-insensitive. + See [Keyword spotting](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#keyword_spotting). :param float keywords_threshold: (optional) A confidence value that is the lower bound for spotting a keyword. A word is considered to match a keyword @@ -844,11 +884,11 @@ def create_job(self, multi-person exchange. By default, the service returns no speaker labels. Setting `speaker_labels` to `true` forces the `timestamps` parameter to be `true`, regardless of whether you specify `false` for the parameter. - **Note:** Applies to US English, Japanese, and Spanish (both broadband and - narrowband models) and UK English (narrowband model) transcription only. To - determine whether a language model supports speaker labels, you can also - use the **Get a model** method and check that the attribute - `speaker_labels` is set to `true`. + **Note:** Applies to US English, German, Japanese, Korean, and Spanish + (both broadband and narrowband models) and UK English (narrowband model) + transcription only. To determine whether a language model supports speaker + labels, you can also use the **Get a model** method and check that the + attribute `speaker_labels` is set to `true`. See [Speaker labels](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#speaker_labels). :param str customization_id: (optional) **Deprecated.** Use the @@ -929,6 +969,30 @@ def create_job(self, transcripts based solely on the pause interval. See [Split transcript at phrase end](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#split_transcript). + :param float speech_detector_sensitivity: (optional) The sensitivity of + speech activity detection that the service is to perform. Use the parameter + to suppress word insertions from music, coughing, and other non-speech + events. The service biases the audio it passes for speech recognition by + evaluating the input audio against prior models of speech and non-speech + activity. + Specify a value between 0.0 and 1.0: + * 0.0 suppresses all audio (no speech is transcribed). + * 0.5 (the default) provides a reasonable compromise for the level of + sensitivity. + * 1.0 suppresses no audio (speech detection sensitivity is disabled). + The values increase on a monotonic curve. See [Speech Activity + Detection](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#detection). + :param float background_audio_suppression: (optional) The level to which + the service is to suppress background audio based on its volume to prevent + it from being transcribed as speech. Use the parameter to suppress side + conversations or background noise. + Specify a value in the range of 0.0 to 1.0: + * 0.0 (the default) provides no suppression (background audio suppression + is disabled). + * 0.5 provides a reasonable level of audio suppression for general usage. + * 1.0 suppresses all audio (no audio is transcribed). + The values increase on a monotonic curve. See [Speech Activity + Detection](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#detection). :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse @@ -972,7 +1036,9 @@ def create_job(self, 'processing_metrics_interval': processing_metrics_interval, 'audio_metrics': audio_metrics, 'end_of_phrase_silence_time': end_of_phrase_silence_time, - 'split_transcript_at_phrase_end': split_transcript_at_phrase_end + 'split_transcript_at_phrase_end': split_transcript_at_phrase_end, + 'speech_detector_sensitivity': speech_detector_sensitivity, + 'background_audio_suppression': background_audio_suppression } data = audio @@ -1195,7 +1261,9 @@ def create_language_model(self, response = self.send(request) return response - def list_language_models(self, *, language: str = None, + def list_language_models(self, + *, + language: str = None, **kwargs) -> 'DetailedResponse': """ List custom language models. @@ -1563,17 +1631,19 @@ def add_corpus(self, better the service's recognition accuracy. The call returns an HTTP 201 response code if the corpus is valid. The service then asynchronously processes the contents of the corpus and automatically - extracts new words that it finds. This can take on the order of a minute or two to - complete depending on the total number of words and the number of new words in the - corpus, as well as the current load on the service. You cannot submit requests to - add additional resources to the custom model or to train the model until the + extracts new words that it finds. This operation can take on the order of minutes + to complete depending on the total number of words and the number of new words in + the corpus, as well as the current load on the service. You cannot submit requests + to add additional resources to the custom model or to train the model until the service's analysis of the corpus for the current request completes. Use the **List a corpus** method to check the status of the analysis. The service auto-populates the model's words resource with words from the corpus - that are not found in its base vocabulary. These are referred to as - out-of-vocabulary (OOV) words. You can use the **List custom words** method to - examine the words resource. You can use other words method to eliminate typos and - modify how words are pronounced as needed. + that are not found in its base vocabulary. These words are referred to as + out-of-vocabulary (OOV) words. After adding a corpus, you must validate the words + resource to ensure that each OOV word's definition is complete and valid. You can + use the **List custom words** method to examine the words resource. You can use + other words method to eliminate typos and modify how words are pronounced as + needed. To add a corpus file that has the same name as an existing corpus, set the `allow_overwrite` parameter to `true`; otherwise, the request fails. Overwriting an existing corpus causes the service to process the corpus text file and extract @@ -1587,10 +1657,12 @@ def add_corpus(self, that the service extracts from corpora and grammars, and words that you add directly. **See also:** + * [Add a corpus to the custom language + model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-languageCreate#addCorpus) * [Working with corpora](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#workingCorpora) - * [Add a corpus to the custom language - model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-languageCreate#addCorpus). + * [Validating a words + resource](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#validateModel). :param str customization_id: The customization ID (GUID) of the custom language model that is to be used for the request. You must make the @@ -1848,7 +1920,10 @@ def add_words(self, customization_id: str, words: List['CustomWord'], the parameter for words that are difficult to pronounce, foreign words, acronyms, and so on. For example, you might specify that the word `IEEE` can sound like `i triple e`. You can specify a maximum of five sounds-like pronunciations for a - word. + word. If you omit the `sounds_like` field, the service attempts to set the field + to its pronunciation of the word. It cannot generate a pronunciation for all + words, so you must review the word's definition to ensure that it is complete and + valid. * The `display_as` field provides a different way of spelling the word in a transcript. Use the parameter when you want the word to appear different from its usual representation or from its spelling in training data. For example, you might @@ -1872,10 +1947,12 @@ def add_words(self, customization_id: str, words: List['CustomWord'], `error` field that describes the problem. You can use other words-related methods to correct errors, eliminate typos, and modify how words are pronounced as needed. **See also:** + * [Add words to the custom language + model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-languageCreate#addWords) * [Working with custom words](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#workingWords) - * [Add words to the custom language - model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-languageCreate#addWords). + * [Validating a words + resource](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#validateModel). :param str customization_id: The customization ID (GUID) of the custom language model that is to be used for the request. You must make the @@ -1944,7 +2021,10 @@ def add_word(self, the parameter for words that are difficult to pronounce, foreign words, acronyms, and so on. For example, you might specify that the word `IEEE` can sound like `i triple e`. You can specify a maximum of five sounds-like pronunciations for a - word. + word. If you omit the `sounds_like` field, the service attempts to set the field + to its pronunciation of the word. It cannot generate a pronunciation for all + words, so you must review the word's definition to ensure that it is complete and + valid. * The `display_as` field provides a different way of spelling the word in a transcript. Use the parameter when you want the word to appear different from its usual representation or from its spelling in training data. For example, you might @@ -1954,10 +2034,12 @@ def add_word(self, service encounters an error, it does not add the word to the words resource. Use the **List a custom word** method to review the word that you add. **See also:** + * [Add words to the custom language + model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-languageCreate#addWords) * [Working with custom words](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#workingWords) - * [Add words to the custom language - model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-languageCreate#addWords). + * [Validating a words + resource](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#validateModel). :param str customization_id: The customization ID (GUID) of the custom language model that is to be used for the request. You must make the @@ -2180,12 +2262,12 @@ def add_grammar(self, custom language model** method. The call returns an HTTP 201 response code if the grammar is valid. The service then asynchronously processes the contents of the grammar and automatically - extracts new words that it finds. This can take a few seconds to complete - depending on the size and complexity of the grammar, as well as the current load - on the service. You cannot submit requests to add additional resources to the - custom model or to train the model until the service's analysis of the grammar for - the current request completes. Use the **Get a grammar** method to check the - status of the analysis. + extracts new words that it finds. This operation can take a few seconds or minutes + to complete depending on the size and complexity of the grammar, as well as the + current load on the service. You cannot submit requests to add additional + resources to the custom model or to train the model until the service's analysis + of the grammar for the current request completes. Use the **Get a grammar** method + to check the status of the analysis. The service populates the model's words resource with any word that is recognized by the grammar that is not found in the model's base vocabulary. These are referred to as out-of-vocabulary (OOV) words. You can use the **List custom @@ -2442,7 +2524,9 @@ def create_acoustic_model(self, response = self.send(request) return response - def list_acoustic_models(self, *, language: str = None, + def list_acoustic_models(self, + *, + language: str = None, **kwargs) -> 'DetailedResponse': """ List custom acoustic models. @@ -2579,7 +2663,7 @@ def train_acoustic_model(self, to complete depending on the total amount of audio data on which the custom acoustic model is being trained and the current load on the service. Typically, training a custom acoustic model takes approximately two to four times the length - of its audio data. The range of time depends on the model being trained and the + of its audio data. The actual time depends on the model being trained and the nature of the audio, such as whether the audio is clean or noisy. The method returns an HTTP 200 response code to indicate that the training process has begun. You can monitor the status of the training by using the **Get a custom acoustic @@ -2595,8 +2679,9 @@ def train_acoustic_model(self, Train with a custom language model if you have verbatim transcriptions of the audio files that you have added to the custom model or you have either corpora (text files) or a list of words that are relevant to the contents of the audio - files. Both of the custom models must be based on the same version of the same - base model for training to succeed. + files. For training to succeed, both of the custom models must be based on the + same version of the same base model, and the custom language model must be fully + trained and available. **See also:** * [Train the custom acoustic model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-acoustic#trainModel-acoustic) @@ -2608,6 +2693,9 @@ def train_acoustic_model(self, another training request or a request to add audio resources to the model. * The custom model contains less than 10 minutes or more than 200 hours of audio data. + * You passed a custom language model with the `custom_language_model_id` query + parameter that is not in the available state. A custom language model must be + fully trained and available to be used to train a custom acoustic model. * You passed an incompatible custom language model with the `custom_language_model_id` query parameter. Both custom models must be based on the same version of the same base model. @@ -2626,8 +2714,9 @@ def train_acoustic_model(self, verbatim transcriptions of the audio resources or that contains words that are relevant to the contents of the audio resources. The custom language model must be based on the same version of the same base model as the - custom acoustic model. The credentials specified with the request must own - both custom models. + custom acoustic model, and the custom language model must be fully trained + and available. The credentials specified with the request must own both + custom models. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse @@ -2740,8 +2829,9 @@ def upgrade_acoustic_model(self, :param str custom_language_model_id: (optional) If the custom acoustic model was trained with a custom language model, the customization ID (GUID) of that custom language model. The custom language model must be upgraded - before the custom acoustic model can be upgraded. The credentials specified - with the request must own both custom models. + before the custom acoustic model can be upgraded. The custom language model + must be fully trained and available. The credentials specified with the + request must own both custom models. :param bool force: (optional) If `true`, forces the upgrade of a custom acoustic model for which no input data has been modified since it was last trained. Use this parameter only to force the upgrade of a custom acoustic @@ -2854,14 +2944,14 @@ def add_audio(self, archive-type, can be larger than 100 MB. To add an audio resource that has the same name as an existing audio resource, set the `allow_overwrite` parameter to `true`; otherwise, the request fails. - The method is asynchronous. It can take several seconds to complete depending on - the duration of the audio and, in the case of an archive file, the total number of - audio files being processed. The service returns a 201 response code if the audio - is valid. It then asynchronously analyzes the contents of the audio file or files - and automatically extracts information about the audio such as its length, - sampling rate, and encoding. You cannot submit requests to train or upgrade the - model until the service's analysis of all audio resources for current requests - completes. + The method is asynchronous. It can take several seconds or minutes to complete + depending on the duration of the audio and, in the case of an archive file, the + total number of audio files being processed. The service returns a 201 response + code if the audio is valid. It then asynchronously analyzes the contents of the + audio file or files and automatically extracts information about the audio such as + its length, sampling rate, and encoding. You cannot submit requests to train or + upgrade the model until the service's analysis of all audio resources for current + requests completes. To determine the status of the service's analysis of the audio, use the **Get an audio resource** method to poll the status of the audio. The method accepts the customization ID of the custom model and the name of the audio resource, and it diff --git a/ibm_watson/speech_to_text_v1_adapter.py b/ibm_watson/speech_to_text_v1_adapter.py index 3585eefb6..22a565c79 100644 --- a/ibm_watson/speech_to_text_v1_adapter.py +++ b/ibm_watson/speech_to_text_v1_adapter.py @@ -53,6 +53,8 @@ def recognize_using_websocket(self, audio_metrics=None, end_of_phrase_silence_time=None, split_transcript_at_phrase_end=None, + speech_detector_sensitivity = None, + background_audio_suppression = None, **kwargs): """ Sends audio for speech recognition using web sockets. @@ -72,7 +74,7 @@ def recognize_using_websocket(self, `model` parameter. You must make the request with service credentials created for the instance of the service that owns the custom model. By default, no custom language model is used. See [Custom - models](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-text-input#custom). + models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#custom). **Note:** Use this parameter instead of the deprecated `customization_id` parameter. :param str acoustic_customization_id: The customization ID (GUID) of a custom @@ -102,16 +104,23 @@ def recognize_using_websocket(self, models that have been upgraded for a new base model. The default value depends on whether the parameter is used with or without a custom model. For more information, see [Base model - version](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-text-input#version). + version](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#version). :param int inactivity_timeout: The time in seconds after which, if only silence (no speech) is detected in submitted audio, the connection is closed with a 400 error. Useful for stopping audio submission from a live microphone when a user simply walks away. Use `-1` for infinity. - :param list[str] keywords: An array of keyword strings to spot in the audio. Each - keyword string can include one or more tokens. Keywords are spotted only in the - final hypothesis, not in interim results. If you specify any keywords, you must - also specify a keywords threshold. You can spot a maximum of 1000 keywords. Omit - the parameter or specify an empty array if you do not need to spot keywords. + :param List[str] keywords: (optional) An array of keyword strings to spot + in the audio. Each keyword string can include one or more string tokens. + Keywords are spotted only in the final results, not in interim hypotheses. + If you specify any keywords, you must also specify a keywords threshold. + Omit the parameter or specify an empty array if you do not need to spot + keywords. + You can spot a maximum of 1000 keywords with a single request. A single + keyword can have a maximum length of 1024 characters, though the maximum + effective length for double-byte languages might be shorter. Keywords are + case-insensitive. + See [Keyword + spotting](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#keyword_spotting). :param float keywords_threshold: A confidence value that is the lower bound for spotting a keyword. A word is considered to match a keyword if its confidence is greater than or equal to the threshold. Specify a probability between 0 and 1 @@ -138,15 +147,18 @@ def recognize_using_websocket(self, request. For US English, also converts certain keyword strings to punctuation symbols. By default, no smart formatting is performed. Applies to US English and Spanish transcription only. - :param bool speaker_labels: If `true`, the response includes labels that identify - which words were spoken by which participants in a multi-person exchange. By - default, no speaker labels are returned. Setting `speaker_labels` to `true` forces - the `timestamps` parameter to be `true`, regardless of whether you specify `false` - for the parameter. - To determine whether a language model supports speaker labels, use the **Get - models** method and check that the attribute `speaker_labels` is set to `true`. - You can also refer to [Speaker - labels](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-text-output#speaker_labels). + :param bool speaker_labels: (optional) If `true`, the response includes + labels that identify which words were spoken by which participants in a + multi-person exchange. By default, the service returns no speaker labels. + Setting `speaker_labels` to `true` forces the `timestamps` parameter to be + `true`, regardless of whether you specify `false` for the parameter. + **Note:** Applies to US English, German, Japanese, Korean, and Spanish + (both broadband and narrowband models) and UK English (narrowband model) + transcription only. To determine whether a language model supports speaker + labels, you can also use the **Get a model** method and check that the + attribute `speaker_labels` is set to `true`. + See [Speaker + labels](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#speaker_labels). :param str http_proxy_host: http proxy host name. :param str http_proxy_port: http proxy port. If not set, set to 80. :param str customization_id: **Deprecated.** Use the `language_customization_id` @@ -159,7 +171,7 @@ def recognize_using_websocket(self, model for which the grammar is defined. The service recognizes only strings that are recognized by the specified grammar; it does not recognize other custom words from the model's words resource. See - [Grammars](https://cloud.ibm.com/docs/services/speech-to-text/output.html). + [Grammars](https://cloud.ibm.com/docs/speech-to-text/output.html). :param bool redaction: If `true`, the service redacts, or masks, numeric data from final transcripts. The feature redacts any number that has three or more consecutive digits by replacing each digit with an `X` character. It is intended @@ -172,7 +184,7 @@ def recognize_using_websocket(self, (forces the `max_alternatives` parameter to be `1`). **Note:** Applies to US English, Japanese, and Korean transcription only. See [Numeric - redaction](https://cloud.ibm.com/docs/services/speech-to-text/output.html#redaction). + redaction](https://cloud.ibm.com/docs/speech-to-text/output.html#redaction). :param bool processing_metrics: If `true`, requests processing metrics about the service's transcription of the input audio. The service returns processing metrics at the interval specified by the `processing_metrics_interval` parameter. It also @@ -204,7 +216,7 @@ def recognize_using_websocket(self, The default pause interval for most languages is 0.8 seconds; the default for Chinese is 0.6 seconds. See [End of phrase silence - time](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-text-output#silence_time). + time](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#silence_time). :param bool split_transcript_at_phrase_end: (optional) If `true`, directs the service to split the transcript into multiple final results based on semantic features of the input, for example, at the conclusion of @@ -214,7 +226,31 @@ def recognize_using_websocket(self, where the service splits a transcript. By default, the service splits transcripts based solely on the pause interval. See [Split transcript at phrase - end](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-text-output#split_transcript). + end](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-output#split_transcript). + :param float speech_detector_sensitivity: (optional) The sensitivity of + speech activity detection that the service is to perform. Use the parameter + to suppress word insertions from music, coughing, and other non-speech + events. The service biases the audio it passes for speech recognition by + evaluating the input audio against prior models of speech and non-speech + activity. + Specify a value between 0.0 and 1.0: + * 0.0 suppresses all audio (no speech is transcribed). + * 0.5 (the default) provides a reasonable compromise for the level of + sensitivity. + * 1.0 suppresses no audio (speech detection sensitivity is disabled). + The values increase on a monotonic curve. See [Speech Activity + Detection](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#detection). + :param float background_audio_suppression: (optional) The level to which + the service is to suppress background audio based on its volume to prevent + it from being transcribed as speech. Use the parameter to suppress side + conversations or background noise. + Specify a value in the range of 0.0 to 1.0: + * 0.0 (the default) provides no suppression (background audio suppression + is disabled). + * 0.5 provides a reasonable level of audio suppression for general usage. + * 1.0 suppresses all audio (no audio is transcribed). + The values increase on a monotonic curve. See [Speech Activity + Detection](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-input#detection). :param dict headers: A `dict` containing the request headers :return: A `dict` containing the `SpeechRecognitionResults` response. :rtype: dict @@ -276,7 +312,11 @@ def recognize_using_websocket(self, 'redaction': redaction, 'processing_metrics': processing_metrics, 'processing_metrics_interval': processing_metrics_interval, - 'audio_metrics': audio_metrics + 'audio_metrics': audio_metrics, + 'end_of_phrase_silence_time': end_of_phrase_silence_time, + 'split_transcript_at_phrase_end': split_transcript_at_phrase_end, + 'speech_detector_sensitivity': speech_detector_sensitivity, + 'background_audio_suppression': background_audio_suppression } options = {k: v for k, v in options.items() if v is not None} request['options'] = options From e9ea20cc68a09da4e948c0622e254c31b27b481b Mon Sep 17 00:00:00 2001 From: Mamoon Raja Date: Thu, 16 Apr 2020 10:04:43 -0400 Subject: [PATCH 04/10] feat: regenerate services using current API def --- ibm_watson/assistant_v1.py | 135 +++++++++++++--- ibm_watson/assistant_v2.py | 153 +++++++++++++++--- ibm_watson/compare_comply_v1.py | 47 ++++-- ibm_watson/discovery_v1.py | 90 +++++++---- ibm_watson/discovery_v2.py | 98 +++++++---- ibm_watson/natural_language_classifier_v1.py | 4 +- .../natural_language_understanding_v1.py | 59 ++++--- ibm_watson/personality_insights_v3.py | 31 ++-- ibm_watson/text_to_speech_adapter_v1.py | 10 +- ibm_watson/text_to_speech_v1.py | 111 +++++++++---- ibm_watson/visual_recognition_v3.py | 9 +- ibm_watson/visual_recognition_v4.py | 42 ++--- 12 files changed, 582 insertions(+), 207 deletions(-) diff --git a/ibm_watson/assistant_v1.py b/ibm_watson/assistant_v1.py index 2020c9bfe..25a8df958 100644 --- a/ibm_watson/assistant_v1.py +++ b/ibm_watson/assistant_v1.py @@ -941,7 +941,7 @@ def create_example(self, Create user input example. Add a new user input example to an intent. - If you want to add multiple exaples with a single API call, consider using the + If you want to add multiple examples with a single API call, consider using the **[Update intent](#update-intent)** method instead. This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**. @@ -2623,7 +2623,8 @@ def create_dialog_node(self, :param str user_label: (optional) A label that can be displayed externally to describe the purpose of the node to users. :param bool disambiguation_opt_out: (optional) Whether the dialog node - should be excluded from disambiguation suggestions. + should be excluded from disambiguation suggestions. Valid only when + **type**=`standard` or `frame`. :param bool include_audit: (optional) Whether to include the audit properties (`created` and `updated` timestamps) in the response. :param dict headers: A `dict` containing the request headers @@ -2809,7 +2810,8 @@ def update_dialog_node(self, :param str new_user_label: (optional) A label that can be displayed externally to describe the purpose of the node to users. :param bool new_disambiguation_opt_out: (optional) Whether the dialog node - should be excluded from disambiguation suggestions. + should be excluded from disambiguation suggestions. Valid only when + **type**=`standard` or `frame`. :param bool include_audit: (optional) Whether to include the audit properties (`created` and `updated` timestamps) in the response. :param dict headers: A `dict` containing the request headers @@ -3978,7 +3980,8 @@ class DialogNode(): :attr str user_label: (optional) A label that can be displayed externally to describe the purpose of the node to users. :attr bool disambiguation_opt_out: (optional) Whether the dialog node should be - excluded from disambiguation suggestions. + excluded from disambiguation suggestions. Valid only when **type**=`standard` or + `frame`. :attr bool disabled: (optional) For internal use only. :attr datetime created: (optional) The timestamp for creation of the object. :attr datetime updated: (optional) The timestamp for the most recent update to @@ -4052,7 +4055,8 @@ def __init__(self, :param str user_label: (optional) A label that can be displayed externally to describe the purpose of the node to users. :param bool disambiguation_opt_out: (optional) Whether the dialog node - should be excluded from disambiguation suggestions. + should be excluded from disambiguation suggestions. Valid only when + **type**=`standard` or `frame`. :param bool disabled: (optional) For internal use only. :param datetime created: (optional) The timestamp for creation of the object. @@ -4776,14 +4780,14 @@ class DialogNodeOutputGeneric(): natural-language query or a query that uses the Discovery query language syntax, depending on the value of the **query_type** property. For more information, see the [Discovery service - documentation](https://cloud.ibm.com/docs/services/discovery/query-operators.html#query-operators). + documentation](https://cloud.ibm.com/docs/discovery/query-operators.html#query-operators). Required when **response_type**=`search_skill`. :attr str query_type: (optional) The type of the search query. Required when **response_type**=`search_skill`. :attr str filter: (optional) An optional filter that narrows the set of documents to be searched. For more information, see the [Discovery service documentation]([Discovery service - documentation](https://cloud.ibm.com/docs/services/discovery/query-parameters.html#filter). + documentation](https://cloud.ibm.com/docs/discovery/query-parameters.html#filter). :attr str discovery_version: (optional) The version of the Discovery service API to use for the query. """ @@ -4845,14 +4849,14 @@ def __init__(self, either a natural-language query or a query that uses the Discovery query language syntax, depending on the value of the **query_type** property. For more information, see the [Discovery service - documentation](https://cloud.ibm.com/docs/services/discovery/query-operators.html#query-operators). + documentation](https://cloud.ibm.com/docs/discovery/query-operators.html#query-operators). Required when **response_type**=`search_skill`. :param str query_type: (optional) The type of the search query. Required when **response_type**=`search_skill`. :param str filter: (optional) An optional filter that narrows the set of documents to be searched. For more information, see the [Discovery service documentation]([Discovery service - documentation](https://cloud.ibm.com/docs/services/discovery/query-parameters.html#filter). + documentation](https://cloud.ibm.com/docs/discovery/query-parameters.html#filter). :param str discovery_version: (optional) The version of the Discovery service API to use for the query. """ @@ -5694,10 +5698,10 @@ class DialogSuggestionResponseGeneric(): :attr str message_to_human_agent: (optional) A message to be sent to the human agent who will be taking over the conversation. :attr str topic: (optional) A label identifying the topic of the conversation, - derived from the **user_label** property of the relevant node. + derived from the **title** property of the relevant node. :attr str dialog_node: (optional) The ID of the dialog node that the **topic** property is taken from. The **topic** property is populated using the value of - the dialog node's **user_label** property. + the dialog node's **title** property. """ def __init__(self, @@ -5739,11 +5743,10 @@ def __init__(self, :param str message_to_human_agent: (optional) A message to be sent to the human agent who will be taking over the conversation. :param str topic: (optional) A label identifying the topic of the - conversation, derived from the **user_label** property of the relevant - node. + conversation, derived from the **title** property of the relevant node. :param str dialog_node: (optional) The ID of the dialog node that the **topic** property is taken from. The **topic** property is populated using - the value of the dialog node's **user_label** property. + the value of the dialog node's **title** property. """ self.response_type = response_type self.text = text @@ -7921,6 +7924,12 @@ class RuntimeEntity(): workspace. For more information about how the new system entities are interpreted, see the [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-beta-system-entities). + :attr List[RuntimeEntityAlternative] alternatives: (optional) An array of + possible alternative values that the user might have intended instead of the + value returned in the **value** property. This property is returned only for + `@sys-time` and `@sys-date` entities when the user's input is ambiguous. + This property is included only if the new system entities are enabled for the + workspace. :attr RuntimeEntityRole role: (optional) An object describing the role played by a system entity that is specifies the beginning or end of a range recognized in the user input. This property is included only if the new system entities are @@ -7936,6 +7945,7 @@ def __init__(self, metadata: dict = None, groups: List['CaptureGroup'] = None, interpretation: 'RuntimeEntityInterpretation' = None, + alternatives: List['RuntimeEntityAlternative'] = None, role: 'RuntimeEntityRole' = None) -> None: """ Initialize a RuntimeEntity object. @@ -7956,6 +7966,13 @@ def __init__(self, For more information about how the new system entities are interpreted, see the [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-beta-system-entities). + :param List[RuntimeEntityAlternative] alternatives: (optional) An array of + possible alternative values that the user might have intended instead of + the value returned in the **value** property. This property is returned + only for `@sys-time` and `@sys-date` entities when the user's input is + ambiguous. + This property is included only if the new system entities are enabled for + the workspace. :param RuntimeEntityRole role: (optional) An object describing the role played by a system entity that is specifies the beginning or end of a range recognized in the user input. This property is included only if the new @@ -7968,6 +7985,7 @@ def __init__(self, self.metadata = metadata self.groups = groups self.interpretation = interpretation + self.alternatives = alternatives self.role = role @classmethod @@ -7976,7 +7994,7 @@ def from_dict(cls, _dict: Dict) -> 'RuntimeEntity': args = {} valid_keys = [ 'entity', 'location', 'value', 'confidence', 'metadata', 'groups', - 'interpretation', 'role' + 'interpretation', 'alternatives', 'role' ] bad_keys = set(_dict.keys()) - set(valid_keys) if bad_keys: @@ -8011,6 +8029,11 @@ def from_dict(cls, _dict: Dict) -> 'RuntimeEntity': if 'interpretation' in _dict: args['interpretation'] = RuntimeEntityInterpretation._from_dict( _dict.get('interpretation')) + if 'alternatives' in _dict: + args['alternatives'] = [ + RuntimeEntityAlternative._from_dict(x) + for x in (_dict.get('alternatives')) + ] if 'role' in _dict: args['role'] = RuntimeEntityRole._from_dict(_dict.get('role')) return cls(**args) @@ -8037,6 +8060,8 @@ def to_dict(self) -> Dict: _dict['groups'] = [x._to_dict() for x in self.groups] if hasattr(self, 'interpretation') and self.interpretation is not None: _dict['interpretation'] = self.interpretation._to_dict() + if hasattr(self, 'alternatives') and self.alternatives is not None: + _dict['alternatives'] = [x._to_dict() for x in self.alternatives] if hasattr(self, 'role') and self.role is not None: _dict['role'] = self.role._to_dict() return _dict @@ -8060,6 +8085,77 @@ def __ne__(self, other: 'RuntimeEntity') -> bool: return not self == other +class RuntimeEntityAlternative(): + """ + An alternative value for the recognized entity. + + :attr str value: (optional) The entity value that was recognized in the user + input. + :attr float confidence: (optional) A decimal percentage that represents Watson's + confidence in the recognized entity. + """ + + def __init__(self, *, value: str = None, confidence: float = None) -> None: + """ + Initialize a RuntimeEntityAlternative object. + + :param str value: (optional) The entity value that was recognized in the + user input. + :param float confidence: (optional) A decimal percentage that represents + Watson's confidence in the recognized entity. + """ + self.value = value + self.confidence = confidence + + @classmethod + def from_dict(cls, _dict: Dict) -> 'RuntimeEntityAlternative': + """Initialize a RuntimeEntityAlternative object from a json dictionary.""" + args = {} + valid_keys = ['value', 'confidence'] + bad_keys = set(_dict.keys()) - set(valid_keys) + if bad_keys: + raise ValueError( + 'Unrecognized keys detected in dictionary for class RuntimeEntityAlternative: ' + + ', '.join(bad_keys)) + if 'value' in _dict: + args['value'] = _dict.get('value') + if 'confidence' in _dict: + args['confidence'] = _dict.get('confidence') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a RuntimeEntityAlternative 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, 'value') and self.value is not None: + _dict['value'] = self.value + if hasattr(self, 'confidence') and self.confidence is not None: + _dict['confidence'] = self.confidence + 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 RuntimeEntityAlternative object.""" + return json.dumps(self._to_dict(), indent=2) + + def __eq__(self, other: 'RuntimeEntityAlternative') -> 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: 'RuntimeEntityAlternative') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class RuntimeEntityInterpretation(): """ RuntimeEntityInterpretation. @@ -8616,10 +8712,10 @@ class RuntimeResponseGeneric(): :attr str message_to_human_agent: (optional) A message to be sent to the human agent who will be taking over the conversation. :attr str topic: (optional) A label identifying the topic of the conversation, - derived from the **user_label** property of the relevant node. + derived from the **title** property of the relevant node. :attr str dialog_node: (optional) The ID of the dialog node that the **topic** property is taken from. The **topic** property is populated using the value of - the dialog node's **user_label** property. + the dialog node's **title** property. :attr List[DialogSuggestion] suggestions: (optional) An array of objects describing the possible matching dialog nodes from which the user can choose. **Note:** The **suggestions** property is part of the disambiguation feature, @@ -8664,11 +8760,10 @@ def __init__(self, :param str message_to_human_agent: (optional) A message to be sent to the human agent who will be taking over the conversation. :param str topic: (optional) A label identifying the topic of the - conversation, derived from the **user_label** property of the relevant - node. + conversation, derived from the **title** property of the relevant node. :param str dialog_node: (optional) The ID of the dialog node that the **topic** property is taken from. The **topic** property is populated using - the value of the dialog node's **user_label** property. + the value of the dialog node's **title** property. :param List[DialogSuggestion] suggestions: (optional) An array of objects describing the possible matching dialog nodes from which the user can choose. diff --git a/ibm_watson/assistant_v2.py b/ibm_watson/assistant_v2.py index 4d95d4fa0..9f0e1fbc2 100644 --- a/ibm_watson/assistant_v2.py +++ b/ibm_watson/assistant_v2.py @@ -1219,17 +1219,21 @@ class MessageContextSkill(): :attr dict user_defined: (optional) Arbitrary variables that can be read and written by a particular skill. - :attr dict system: (optional) For internal use only. + :attr MessageContextSkillSystem system: (optional) System context data used by + the skill. """ - def __init__(self, *, user_defined: dict = None, - system: dict = None) -> None: + def __init__(self, + *, + user_defined: dict = None, + system: 'MessageContextSkillSystem' = None) -> None: """ Initialize a MessageContextSkill object. :param dict user_defined: (optional) Arbitrary variables that can be read and written by a particular skill. - :param dict system: (optional) For internal use only. + :param MessageContextSkillSystem system: (optional) System context data + used by the skill. """ self.user_defined = user_defined self.system = system @@ -1247,7 +1251,8 @@ def from_dict(cls, _dict: Dict) -> 'MessageContextSkill': if 'user_defined' in _dict: args['user_defined'] = _dict.get('user_defined') if 'system' in _dict: - args['system'] = _dict.get('system') + args['system'] = MessageContextSkillSystem._from_dict( + _dict.get('system')) return cls(**args) @classmethod @@ -1261,7 +1266,7 @@ def to_dict(self) -> Dict: if hasattr(self, 'user_defined') and self.user_defined is not None: _dict['user_defined'] = self.user_defined if hasattr(self, 'system') and self.system is not None: - _dict['system'] = self.system + _dict['system'] = self.system._to_dict() return _dict def _to_dict(self): @@ -1283,6 +1288,89 @@ def __ne__(self, other: 'MessageContextSkill') -> bool: return not self == other +class MessageContextSkillSystem(): + """ + System context data used by the skill. + + :attr str state: (optional) An encoded string representing the current + conversation state. By saving this value and then sending it in the context of a + subsequent message request, you can restore the conversation to the same state. + This can be useful if you need to return to an earlier point in the conversation + or resume a paused conversation after the session has expired. + """ + + def __init__(self, *, state: str = None, **kwargs) -> None: + """ + Initialize a MessageContextSkillSystem object. + + :param str state: (optional) An encoded string representing the current + conversation state. By saving this value and then sending it in the context + of a subsequent message request, you can restore the conversation to the + same state. This can be useful if you need to return to an earlier point in + the conversation or resume a paused conversation after the session has + expired. + :param **kwargs: (optional) Any additional properties. + """ + self.state = state + for _key, _value in kwargs.items(): + setattr(self, _key, _value) + + @classmethod + def from_dict(cls, _dict: Dict) -> 'MessageContextSkillSystem': + """Initialize a MessageContextSkillSystem object from a json dictionary.""" + args = {} + xtra = _dict.copy() + if 'state' in _dict: + args['state'] = _dict.get('state') + del xtra['state'] + args.update(xtra) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a MessageContextSkillSystem 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, 'state') and self.state is not None: + _dict['state'] = self.state + if hasattr(self, '_additionalProperties'): + for _key in self._additionalProperties: + _value = getattr(self, _key, None) + if _value is not None: + _dict[_key] = _value + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __setattr__(self, name: str, value: object) -> None: + properties = {'state'} + if not hasattr(self, '_additionalProperties'): + super(MessageContextSkillSystem, + self).__setattr__('_additionalProperties', set()) + if name not in properties: + self._additionalProperties.add(name) + super(MessageContextSkillSystem, self).__setattr__(name, value) + + def __str__(self) -> str: + """Return a `str` version of this MessageContextSkillSystem object.""" + return json.dumps(self._to_dict(), indent=2) + + def __eq__(self, other: 'MessageContextSkillSystem') -> 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: 'MessageContextSkillSystem') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class MessageContextSkills(): """ Information specific to particular skills used by the Assistant. @@ -1488,16 +1576,23 @@ class MessageInputOptions(): Optional properties that control how the assistant responds. :attr bool debug: (optional) Whether to return additional diagnostic - information. Set to `true` to return additional information under the - `output.debug` key. + information. Set to `true` to return additional information in the + `output.debug` property. If you also specify **return_context**=`true`, the + returned skill context includes the `system.state` property. :attr bool restart: (optional) Whether to restart dialog processing at the root of the dialog, regardless of any previously visited nodes. **Note:** This does not affect `turn_count` or any other context variables. :attr bool alternate_intents: (optional) Whether to return more than one intent. Set to `true` to return all matching intents. :attr bool return_context: (optional) Whether to return session context with the - response. If you specify `true`, the response will include the `context` - property. + response. If you specify `true`, the response includes the `context` property. + If you also specify **debug**=`true`, the returned skill context includes the + `system.state` property. + :attr bool export: (optional) Whether to return session context, including full + conversation state. If you specify `true`, the response includes the `context` + property, and the skill context includes the `system.state` property. + **Note:** If **export**=`true`, the context is returned regardless of the value + of **return_context**. """ def __init__(self, @@ -1505,32 +1600,44 @@ def __init__(self, debug: bool = None, restart: bool = None, alternate_intents: bool = None, - return_context: bool = None) -> None: + return_context: bool = None, + export: bool = None) -> None: """ Initialize a MessageInputOptions object. :param bool debug: (optional) Whether to return additional diagnostic - information. Set to `true` to return additional information under the - `output.debug` key. + information. Set to `true` to return additional information in the + `output.debug` property. If you also specify **return_context**=`true`, the + returned skill context includes the `system.state` property. :param bool restart: (optional) Whether to restart dialog processing at the root of the dialog, regardless of any previously visited nodes. **Note:** This does not affect `turn_count` or any other context variables. :param bool alternate_intents: (optional) Whether to return more than one intent. Set to `true` to return all matching intents. :param bool return_context: (optional) Whether to return session context - with the response. If you specify `true`, the response will include the - `context` property. + with the response. If you specify `true`, the response includes the + `context` property. If you also specify **debug**=`true`, the returned + skill context includes the `system.state` property. + :param bool export: (optional) Whether to return session context, including + full conversation state. If you specify `true`, the response includes the + `context` property, and the skill context includes the `system.state` + property. + **Note:** If **export**=`true`, the context is returned regardless of the + value of **return_context**. """ self.debug = debug self.restart = restart self.alternate_intents = alternate_intents self.return_context = return_context + self.export = export @classmethod def from_dict(cls, _dict: Dict) -> 'MessageInputOptions': """Initialize a MessageInputOptions object from a json dictionary.""" args = {} - valid_keys = ['debug', 'restart', 'alternate_intents', 'return_context'] + valid_keys = [ + 'debug', 'restart', 'alternate_intents', 'return_context', 'export' + ] bad_keys = set(_dict.keys()) - set(valid_keys) if bad_keys: raise ValueError( @@ -1544,6 +1651,8 @@ def from_dict(cls, _dict: Dict) -> 'MessageInputOptions': args['alternate_intents'] = _dict.get('alternate_intents') if 'return_context' in _dict: args['return_context'] = _dict.get('return_context') + if 'export' in _dict: + args['export'] = _dict.get('export') return cls(**args) @classmethod @@ -1563,6 +1672,8 @@ def to_dict(self) -> Dict: _dict['alternate_intents'] = self.alternate_intents if hasattr(self, 'return_context') and self.return_context is not None: _dict['return_context'] = self.return_context + if hasattr(self, 'export') and self.export is not None: + _dict['export'] = self.export return _dict def _to_dict(self): @@ -1836,8 +1947,8 @@ class MessageResponse(): :attr MessageOutput output: Assistant output to be rendered or processed by the client. - :attr MessageContext context: (optional) State information for the conversation. - The context is stored by the assistant on a per-session basis. You can use this + :attr MessageContext context: (optional) Context data for the conversation. The + context is stored by the assistant on a per-session basis. You can use this property to access context variables. **Note:** The context is included in message responses only if **return_context**=`true` in the message request. @@ -1852,7 +1963,7 @@ def __init__(self, :param MessageOutput output: Assistant output to be rendered or processed by the client. - :param MessageContext context: (optional) State information for the + :param MessageContext context: (optional) Context data for the conversation. The context is stored by the assistant on a per-session basis. You can use this property to access context variables. **Note:** The context is included in message responses only if @@ -3191,7 +3302,9 @@ class SearchResultMetadata(): indicates a greater match to the query parameters. """ - def __init__(self, *, confidence: float = None, + def __init__(self, + *, + confidence: float = None, score: float = None) -> None: """ Initialize a SearchResultMetadata object. diff --git a/ibm_watson/compare_comply_v1.py b/ibm_watson/compare_comply_v1.py index f701adc77..85ef86f45 100644 --- a/ibm_watson/compare_comply_v1.py +++ b/ibm_watson/compare_comply_v1.py @@ -487,7 +487,10 @@ def list_feedback(self, response = self.send(request) return response - def get_feedback(self, feedback_id: str, *, model: str = None, + def get_feedback(self, + feedback_id: str, + *, + model: str = None, **kwargs) -> 'DetailedResponse': """ Get a specified feedback entry. @@ -528,7 +531,10 @@ def get_feedback(self, feedback_id: str, *, model: str = None, response = self.send(request) return response - def delete_feedback(self, feedback_id: str, *, model: str = None, + def delete_feedback(self, + feedback_id: str, + *, + model: str = None, **kwargs) -> 'DetailedResponse': """ Delete a specified feedback entry. @@ -589,10 +595,10 @@ def create_batch(self, Run Compare and Comply methods over a collection of input documents. **Important:** Batch processing requires the use of the [IBM Cloud Object Storage - service](https://cloud.ibm.com/docs/services/cloud-object-storage?topic=cloud-object-storage-about#about-ibm-cloud-object-storage). + service](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-about#about-ibm-cloud-object-storage). The use of IBM Cloud Object Storage with Compare and Comply is discussed at [Using batch - processing](https://cloud.ibm.com/docs/services/compare-comply?topic=compare-comply-batching#before-you-batch). + processing](https://cloud.ibm.com/docs/compare-comply?topic=compare-comply-batching#before-you-batch). :param str function: The Compare and Comply method to run across the submitted input documents. @@ -996,7 +1002,9 @@ class Address(): `end`. """ - def __init__(self, *, text: str = None, + def __init__(self, + *, + text: str = None, location: 'Location' = None) -> None: """ Initialize a Address object. @@ -1725,7 +1733,9 @@ class Category(): IBM to provide feedback or receive support. """ - def __init__(self, *, label: str = None, + def __init__(self, + *, + label: str = None, provenance_ids: List[str] = None) -> None: """ Initialize a Category object. @@ -2502,7 +2512,9 @@ class Contexts(): `end`. """ - def __init__(self, *, text: str = None, + def __init__(self, + *, + text: str = None, location: 'Location' = None) -> None: """ Initialize a Contexts object. @@ -3150,7 +3162,10 @@ class DocInfo(): :attr str hash: (optional) The MD5 hash of the input document. """ - def __init__(self, *, html: str = None, title: str = None, + def __init__(self, + *, + html: str = None, + title: str = None, hash: str = None) -> None: """ Initialize a DocInfo object. @@ -4761,7 +4776,9 @@ class KeyValuePair(): :attr List[Value] value: (optional) A list of values in a key-value pair. """ - def __init__(self, *, key: 'Key' = None, + def __init__(self, + *, + key: 'Key' = None, value: List['Value'] = None) -> None: """ Initialize a KeyValuePair object. @@ -5070,7 +5087,9 @@ class Mention(): `end`. """ - def __init__(self, *, text: str = None, + def __init__(self, + *, + text: str = None, location: 'Location' = None) -> None: """ Initialize a Mention object. @@ -5896,7 +5915,9 @@ class SectionTitle(): `end`. """ - def __init__(self, *, text: str = None, + def __init__(self, + *, + text: str = None, location: 'Location' = None) -> None: """ Initialize a SectionTitle object. @@ -6369,7 +6390,9 @@ class TableTitle(): :attr str text: (optional) The text of the identified table title or caption. """ - def __init__(self, *, location: 'Location' = None, + def __init__(self, + *, + location: 'Location' = None, text: str = None) -> None: """ Initialize a TableTitle object. diff --git a/ibm_watson/discovery_v1.py b/ibm_watson/discovery_v1.py index 15717d031..2fa04f3b4 100644 --- a/ibm_watson/discovery_v1.py +++ b/ibm_watson/discovery_v1.py @@ -134,7 +134,9 @@ def create_environment(self, response = self.send(request) return response - def list_environments(self, *, name: str = None, + def list_environments(self, + *, + name: str = None, **kwargs) -> 'DetailedResponse': """ List environments. @@ -1611,7 +1613,7 @@ def query(self, By using this method, you can construct long queries. For details, see the [Discovery - documentation](https://cloud.ibm.com/docs/services/discovery?topic=discovery-query-concepts#query-concepts). + documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-concepts#query-concepts). :param str environment_id: The ID of the environment. :param str collection_id: The ID of the collection. @@ -1771,7 +1773,7 @@ def query_notices(self, Queries for notices (errors or warnings) that might have been generated by the system. Notices are generated when ingesting documents and performing relevance training. See the [Discovery - documentation](https://cloud.ibm.com/docs/services/discovery?topic=discovery-query-concepts#query-concepts) + documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-concepts#query-concepts) for more details on the query language. :param str environment_id: The ID of the environment. @@ -1909,7 +1911,7 @@ def federated_query(self, By using this method, you can construct long queries that search multiple collection. For details, see the [Discovery - documentation](https://cloud.ibm.com/docs/services/discovery?topic=discovery-query-concepts#query-concepts). + documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-concepts#query-concepts). :param str environment_id: The ID of the environment. :param str collection_ids: A comma-separated list of collection IDs to be @@ -2060,7 +2062,7 @@ def federated_query_notices(self, Queries for notices (errors or warnings) that might have been generated by the system. Notices are generated when ingesting documents and performing relevance training. See the [Discovery - documentation](https://cloud.ibm.com/docs/services/discovery?topic=discovery-query-concepts#query-concepts) + documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-concepts#query-concepts) for more details on the query language. :param str environment_id: The ID of the environment. @@ -2715,7 +2717,7 @@ def delete_user_data(self, customer_id: str, You associate a customer ID with data by passing the **X-Watson-Metadata** header with a request that passes data. For more information about personal data and customer IDs, see [Information - security](https://cloud.ibm.com/docs/services/discovery?topic=discovery-information-security#information-security). + security](https://cloud.ibm.com/docs/discovery?topic=discovery-information-security#information-security). :param str customer_id: The customer ID for which all data is to be deleted. @@ -3047,7 +3049,9 @@ def get_metrics_event_rate(self, response = self.send(request) return response - def get_metrics_query_token_event(self, *, count: int = None, + def get_metrics_query_token_event(self, + *, + count: int = None, **kwargs) -> 'DetailedResponse': """ Most frequent query tokens with an event. @@ -3396,7 +3400,10 @@ def list_gateways(self, environment_id: str, response = self.send(request) return response - def create_gateway(self, environment_id: str, *, name: str = None, + def create_gateway(self, + environment_id: str, + *, + name: str = None, **kwargs) -> 'DetailedResponse': """ Create Gateway. @@ -4001,7 +4008,9 @@ class CollectionUsage(): environment. """ - def __init__(self, *, available: int = None, + def __init__(self, + *, + available: int = None, maximum_allowed: int = None) -> None: """ Initialize a CollectionUsage object. @@ -4562,12 +4571,12 @@ class CredentialDetails(): object store. Only valid, and required, with a **credential_type** of `aws4_hmac`. This value is never returned and is only used when creating or modifying **credentials**. For more infomation, see the [cloud object store - documentation](https://cloud.ibm.com/docs/services/cloud-object-storage?topic=cloud-object-storage-using-hmac-credentials#using-hmac-credentials). + documentation](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-using-hmac-credentials#using-hmac-credentials). :attr str secret_access_key: (optional) The secret access key associated with the cloud object store. Only valid, and required, with a **credential_type** of `aws4_hmac`. This value is never returned and is only used when creating or modifying **credentials**. For more infomation, see the [cloud object store - documentation](https://cloud.ibm.com/docs/services/cloud-object-storage?topic=cloud-object-storage-using-hmac-credentials#using-hmac-credentials). + documentation](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-using-hmac-credentials#using-hmac-credentials). """ def __init__(self, @@ -4669,13 +4678,13 @@ def __init__(self, cloud object store. Only valid, and required, with a **credential_type** of `aws4_hmac`. This value is never returned and is only used when creating or modifying **credentials**. For more infomation, see the [cloud object store - documentation](https://cloud.ibm.com/docs/services/cloud-object-storage?topic=cloud-object-storage-using-hmac-credentials#using-hmac-credentials). + documentation](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-using-hmac-credentials#using-hmac-credentials). :param str secret_access_key: (optional) The secret access key associated with the cloud object store. Only valid, and required, with a **credential_type** of `aws4_hmac`. This value is never returned and is only used when creating or modifying **credentials**. For more infomation, see the [cloud object store - documentation](https://cloud.ibm.com/docs/services/cloud-object-storage?topic=cloud-object-storage-using-hmac-credentials#using-hmac-credentials). + documentation](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-using-hmac-credentials#using-hmac-credentials). """ self.credential_type = credential_type self.client_id = client_id @@ -5262,7 +5271,9 @@ class DeleteCredentials(): :attr str status: (optional) The status of the deletion request. """ - def __init__(self, *, credential_id: str = None, + def __init__(self, + *, + credential_id: str = None, status: str = None) -> None: """ Initialize a DeleteCredentials object. @@ -5944,7 +5955,7 @@ class Enrichment(): Classification options. Additionally, when using the `elements` enrichment the configuration specified and files ingested must meet all the criteria specified in [the - documentation](https://cloud.ibm.com/docs/services/discovery?topic=discovery-element-classification#element-classification). + documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-element-classification#element-classification). :attr bool ignore_downstream_errors: (optional) If true, then most errors generated during the enrichment process will be treated as warnings and will not cause the document to fail processing. @@ -5979,7 +5990,7 @@ def __init__(self, Classification options. Additionally, when using the `elements` enrichment the configuration specified and files ingested must meet all the criteria specified in [the - documentation](https://cloud.ibm.com/docs/services/discovery?topic=discovery-element-classification#element-classification). + documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-element-classification#element-classification). :param str description: (optional) Describes what the enrichment step does. :param bool overwrite: (optional) Indicates that the enrichments will overwrite the destination_field field if it already exists. @@ -6394,36 +6405,38 @@ class EnvironmentDocuments(): """ Summary of the document usage statistics for the environment. - :attr int indexed: (optional) Number of documents indexed for the environment. + :attr int available: (optional) Number of documents indexed for the environment. :attr int maximum_allowed: (optional) Total number of documents allowed in the environment's capacity. """ - def __init__(self, *, indexed: int = None, + def __init__(self, + *, + available: int = None, maximum_allowed: int = None) -> None: """ Initialize a EnvironmentDocuments object. - :param int indexed: (optional) Number of documents indexed for the + :param int available: (optional) Number of documents indexed for the environment. :param int maximum_allowed: (optional) Total number of documents allowed in the environment's capacity. """ - self.indexed = indexed + self.available = available self.maximum_allowed = maximum_allowed @classmethod def from_dict(cls, _dict: Dict) -> 'EnvironmentDocuments': """Initialize a EnvironmentDocuments object from a json dictionary.""" args = {} - valid_keys = ['indexed', 'maximum_allowed'] + valid_keys = ['available', 'maximum_allowed'] bad_keys = set(_dict.keys()) - set(valid_keys) if bad_keys: raise ValueError( 'Unrecognized keys detected in dictionary for class EnvironmentDocuments: ' + ', '.join(bad_keys)) - if 'indexed' in _dict: - args['indexed'] = _dict.get('indexed') + if 'available' in _dict: + args['available'] = _dict.get('available') if 'maximum_allowed' in _dict: args['maximum_allowed'] = _dict.get('maximum_allowed') return cls(**args) @@ -6436,8 +6449,8 @@ def _from_dict(cls, _dict): def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'indexed') and self.indexed is not None: - _dict['indexed'] = self.indexed + if hasattr(self, 'available') and self.available is not None: + _dict['available'] = self.available if hasattr(self, 'maximum_allowed') and self.maximum_allowed is not None: _dict['maximum_allowed'] = self.maximum_allowed @@ -8429,7 +8442,8 @@ class MetricResponse(): aggregations. """ - def __init__(self, *, + def __init__(self, + *, aggregations: List['MetricAggregation'] = None) -> None: """ Initialize a MetricResponse object. @@ -8657,7 +8671,8 @@ class MetricTokenResponse(): token aggregations. """ - def __init__(self, *, + def __init__(self, + *, aggregations: List['MetricTokenAggregation'] = None) -> None: """ Initialize a MetricTokenResponse object. @@ -8854,7 +8869,9 @@ class NluEnrichmentEmotion(): that will have any associated emotions detected. """ - def __init__(self, *, document: bool = None, + def __init__(self, + *, + document: bool = None, targets: List[str] = None) -> None: """ Initialize a NluEnrichmentEmotion object. @@ -9438,7 +9455,9 @@ class NluEnrichmentSentiment(): that will have any associated sentiment analyzed. """ - def __init__(self, *, document: bool = None, + def __init__(self, + *, + document: bool = None, targets: List[str] = None) -> None: """ Initialize a NluEnrichmentSentiment object. @@ -11065,7 +11084,9 @@ class SduStatusCustomFields(): are allowed in this collection. """ - def __init__(self, *, defined: int = None, + def __init__(self, + *, + defined: int = None, maximum_allowed: int = None) -> None: """ Initialize a SduStatusCustomFields object. @@ -11709,7 +11730,10 @@ class SourceOptionsFolder(): folder. By default, all documents in the folder are crawled. """ - def __init__(self, owner_user_id: str, folder_id: str, *, + def __init__(self, + owner_user_id: str, + folder_id: str, + *, limit: int = None) -> None: """ Initialize a SourceOptionsFolder object. @@ -12256,7 +12280,9 @@ class SourceStatus(): time of the next crawl attempt. """ - def __init__(self, *, status: str = None, + def __init__(self, + *, + status: str = None, next_crawl: datetime = None) -> None: """ Initialize a SourceStatus object. diff --git a/ibm_watson/discovery_v2.py b/ibm_watson/discovery_v2.py index 4578d4d8e..569b17cf7 100644 --- a/ibm_watson/discovery_v2.py +++ b/ibm_watson/discovery_v2.py @@ -146,7 +146,7 @@ def query(self, Query a project. By using this method, you can construct queries. For details, see the [Discovery - documentation](https://cloud.ibm.com/docs/services/discovery-data?topic=discovery-data-query-concepts). + documentation](https://cloud.ibm.com/docs/discovery-data?topic=discovery-data-query-concepts). :param str project_id: The ID of the project. This information can be found from the deploy page of the Discovery administrative tooling. @@ -1432,14 +1432,14 @@ class ComponentSettingsResponse(): component setting aggregations. """ - def __init__(self, - *, - fields_shown: 'ComponentSettingsFieldsShown' = None, - autocomplete: bool = None, - structured_search: bool = None, - results_per_page: int = None, - aggregations: List['ComponentSettingsAggregation'] = None - ) -> None: + def __init__( + self, + *, + fields_shown: 'ComponentSettingsFieldsShown' = None, + autocomplete: bool = None, + structured_search: bool = None, + results_per_page: int = None, + aggregations: List['ComponentSettingsAggregation'] = None) -> None: """ Initialize a ComponentSettingsResponse object. @@ -3543,7 +3543,9 @@ class QueryTopHitsAggregationResult(): :attr List[dict] hits: (optional) An array of the document results. """ - def __init__(self, matching_results: int, *, + def __init__(self, + matching_results: int, + *, hits: List[dict] = None) -> None: """ Initialize a QueryTopHitsAggregationResult object. @@ -5817,17 +5819,20 @@ class QueryHistogramAggregation(QueryAggregation): :attr str field: The numeric field name used to create the histogram. :attr int interval: The size of the sections the results are split into. + :attr str name: (optional) Identifier specified in the query request of this + aggregation. :attr List[QueryHistogramAggregationResult] results: (optional) Array of numeric intervals. """ - def __init__(self, - type: str, - field: str, - interval: int, - *, - results: List['QueryHistogramAggregationResult'] = None - ) -> None: + def __init__( + self, + type: str, + field: str, + interval: int, + *, + name: str = None, + results: List['QueryHistogramAggregationResult'] = None) -> None: """ Initialize a QueryHistogramAggregation object. @@ -5836,19 +5841,22 @@ def __init__(self, unique_count, and top_hits. :param str field: The numeric field name used to create the histogram. :param int interval: The size of the sections the results are split into. + :param str name: (optional) Identifier specified in the query request of + this aggregation. :param List[QueryHistogramAggregationResult] results: (optional) Array of numeric intervals. """ self.type = type self.field = field self.interval = interval + self.name = name self.results = results @classmethod def from_dict(cls, _dict: Dict) -> 'QueryHistogramAggregation': """Initialize a QueryHistogramAggregation object from a json dictionary.""" args = {} - valid_keys = ['type', 'field', 'interval', 'results'] + valid_keys = ['type', 'field', 'interval', 'name', 'results'] bad_keys = set(_dict.keys()) - set(valid_keys) if bad_keys: raise ValueError( @@ -5872,6 +5880,8 @@ def from_dict(cls, _dict: Dict) -> 'QueryHistogramAggregation': raise ValueError( 'Required property \'interval\' not present in QueryHistogramAggregation JSON' ) + if 'name' in _dict: + args['name'] = _dict.get('name') if 'results' in _dict: args['results'] = [ QueryHistogramAggregationResult._from_dict(x) @@ -5893,6 +5903,8 @@ def to_dict(self) -> Dict: _dict['field'] = self.field if hasattr(self, 'interval') and self.interval is not None: _dict['interval'] = self.interval + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name if hasattr(self, 'results') and self.results is not None: _dict['results'] = [x._to_dict() for x in self.results] return _dict @@ -6031,6 +6043,8 @@ class QueryTermAggregation(QueryAggregation): :attr str field: The field in the document used to generate top values from. :attr int count: (optional) The number of top values returned. + :attr str name: (optional) Identifier specified in the query request of this + aggregation. :attr List[QueryTermAggregationResult] results: (optional) Array of top values for the field. """ @@ -6040,6 +6054,7 @@ def __init__(self, field: str, *, count: int = None, + name: str = None, results: List['QueryTermAggregationResult'] = None) -> None: """ Initialize a QueryTermAggregation object. @@ -6050,19 +6065,22 @@ def __init__(self, :param str field: The field in the document used to generate top values from. :param int count: (optional) The number of top values returned. + :param str name: (optional) Identifier specified in the query request of + this aggregation. :param List[QueryTermAggregationResult] results: (optional) Array of top values for the field. """ self.type = type self.field = field self.count = count + self.name = name self.results = results @classmethod def from_dict(cls, _dict: Dict) -> 'QueryTermAggregation': """Initialize a QueryTermAggregation object from a json dictionary.""" args = {} - valid_keys = ['type', 'field', 'count', 'results'] + valid_keys = ['type', 'field', 'count', 'name', 'results'] bad_keys = set(_dict.keys()) - set(valid_keys) if bad_keys: raise ValueError( @@ -6082,6 +6100,8 @@ def from_dict(cls, _dict: Dict) -> 'QueryTermAggregation': ) if 'count' in _dict: args['count'] = _dict.get('count') + if 'name' in _dict: + args['name'] = _dict.get('name') if 'results' in _dict: args['results'] = [ QueryTermAggregationResult._from_dict(x) @@ -6103,6 +6123,8 @@ def to_dict(self) -> Dict: _dict['field'] = self.field if hasattr(self, 'count') and self.count is not None: _dict['count'] = self.count + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name if hasattr(self, 'results') and self.results is not None: _dict['results'] = [x._to_dict() for x in self.results] return _dict @@ -6133,17 +6155,20 @@ class QueryTimesliceAggregation(QueryAggregation): :attr str field: The date field name used to create the timeslice. :attr str interval: The date interval value. Valid values are seconds, minutes, hours, days, weeks, and years. + :attr str name: (optional) Identifier specified in the query request of this + aggregation. :attr List[QueryTimesliceAggregationResult] results: (optional) Array of aggregation results. """ - def __init__(self, - type: str, - field: str, - interval: str, - *, - results: List['QueryTimesliceAggregationResult'] = None - ) -> None: + def __init__( + self, + type: str, + field: str, + interval: str, + *, + name: str = None, + results: List['QueryTimesliceAggregationResult'] = None) -> None: """ Initialize a QueryTimesliceAggregation object. @@ -6153,19 +6178,22 @@ def __init__(self, :param str field: The date field name used to create the timeslice. :param str interval: The date interval value. Valid values are seconds, minutes, hours, days, weeks, and years. + :param str name: (optional) Identifier specified in the query request of + this aggregation. :param List[QueryTimesliceAggregationResult] results: (optional) Array of aggregation results. """ self.type = type self.field = field self.interval = interval + self.name = name self.results = results @classmethod def from_dict(cls, _dict: Dict) -> 'QueryTimesliceAggregation': """Initialize a QueryTimesliceAggregation object from a json dictionary.""" args = {} - valid_keys = ['type', 'field', 'interval', 'results'] + valid_keys = ['type', 'field', 'interval', 'name', 'results'] bad_keys = set(_dict.keys()) - set(valid_keys) if bad_keys: raise ValueError( @@ -6189,6 +6217,8 @@ def from_dict(cls, _dict: Dict) -> 'QueryTimesliceAggregation': raise ValueError( 'Required property \'interval\' not present in QueryTimesliceAggregation JSON' ) + if 'name' in _dict: + args['name'] = _dict.get('name') if 'results' in _dict: args['results'] = [ QueryTimesliceAggregationResult._from_dict(x) @@ -6210,6 +6240,8 @@ def to_dict(self) -> Dict: _dict['field'] = self.field if hasattr(self, 'interval') and self.interval is not None: _dict['interval'] = self.interval + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name if hasattr(self, 'results') and self.results is not None: _dict['results'] = [x._to_dict() for x in self.results] return _dict @@ -6238,6 +6270,8 @@ class QueryTopHitsAggregation(QueryAggregation): Returns the top documents ranked by the score of the query. :attr int size: The number of documents to return. + :attr str name: (optional) Identifier specified in the query request of this + aggregation. :attr QueryTopHitsAggregationResult hits: (optional) """ @@ -6245,6 +6279,7 @@ def __init__(self, type: str, size: int, *, + name: str = None, hits: 'QueryTopHitsAggregationResult' = None) -> None: """ Initialize a QueryTopHitsAggregation object. @@ -6253,17 +6288,20 @@ def __init__(self, term, histogram, timeslice, nested, filter, min, max, sum, average, unique_count, and top_hits. :param int size: The number of documents to return. + :param str name: (optional) Identifier specified in the query request of + this aggregation. :param QueryTopHitsAggregationResult hits: (optional) """ self.type = type self.size = size + self.name = name self.hits = hits @classmethod def from_dict(cls, _dict: Dict) -> 'QueryTopHitsAggregation': """Initialize a QueryTopHitsAggregation object from a json dictionary.""" args = {} - valid_keys = ['type', 'size', 'hits'] + valid_keys = ['type', 'size', 'name', 'hits'] bad_keys = set(_dict.keys()) - set(valid_keys) if bad_keys: raise ValueError( @@ -6281,6 +6319,8 @@ def from_dict(cls, _dict: Dict) -> 'QueryTopHitsAggregation': raise ValueError( 'Required property \'size\' not present in QueryTopHitsAggregation JSON' ) + if 'name' in _dict: + args['name'] = _dict.get('name') if 'hits' in _dict: args['hits'] = QueryTopHitsAggregationResult._from_dict( _dict.get('hits')) @@ -6298,6 +6338,8 @@ def to_dict(self) -> Dict: _dict['type'] = self.type if hasattr(self, 'size') and self.size is not None: _dict['size'] = self.size + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name if hasattr(self, 'hits') and self.hits is not None: _dict['hits'] = self.hits._to_dict() return _dict diff --git a/ibm_watson/natural_language_classifier_v1.py b/ibm_watson/natural_language_classifier_v1.py index 282fecef8..5441a6f68 100644 --- a/ibm_watson/natural_language_classifier_v1.py +++ b/ibm_watson/natural_language_classifier_v1.py @@ -491,7 +491,9 @@ class ClassifiedClass(): :attr str class_name: (optional) Class label. """ - def __init__(self, *, confidence: float = None, + def __init__(self, + *, + confidence: float = None, class_name: str = None) -> None: """ Initialize a ClassifiedClass object. diff --git a/ibm_watson/natural_language_understanding_v1.py b/ibm_watson/natural_language_understanding_v1.py index 961999177..d1ab59e6d 100644 --- a/ibm_watson/natural_language_understanding_v1.py +++ b/ibm_watson/natural_language_understanding_v1.py @@ -19,7 +19,7 @@ request. The service cleans HTML content before analysis by default, so the results can ignore most advertisements and other unwanted content. You can create [custom -models](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-customizing) +models](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing) with Watson Knowledge Studio to detect custom entities and relations in Natural Language Understanding. """ @@ -113,7 +113,7 @@ def analyze(self, - Syntax (Experimental). If a language for the input text is not specified with the `language` parameter, the service [automatically detects the - language](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-detectable-languages). + language](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-detectable-languages). :param Features features: Specific features to analyze the document for. :param str text: (optional) The plain text to analyze. One of the `text`, @@ -124,10 +124,10 @@ def analyze(self, `html`, or `url` parameters is required. :param bool clean: (optional) Set this to `false` to disable webpage cleaning. To learn more about webpage cleaning, see the [Analyzing - webpages](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-analyzing-webpages) + webpages](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-analyzing-webpages) documentation. :param str xpath: (optional) An [XPath - query](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-analyzing-webpages#xpath) + query](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-analyzing-webpages#xpath) to perform on `html` or `url` input. Results of the query will be appended to the cleaned webpage text before it is analyzed. To analyze only the results of the XPath query, set the `clean` parameter to `false`. @@ -139,7 +139,7 @@ def analyze(self, of your text. This overrides automatic language detection. Language support differs depending on the features you include in your analysis. See [Language - support](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-language-support) + support](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-language-support) for more information. :param int limit_text_characters: (optional) Sets the maximum number of characters that are processed by the service. @@ -194,7 +194,7 @@ def list_models(self, **kwargs) -> 'DetailedResponse': List models. Lists Watson Knowledge Studio [custom entities and relations - models](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-customizing) + models](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing) that are deployed to your Natural Language Understanding service. :param dict headers: A `dict` containing the request headers @@ -718,7 +718,7 @@ class CategoriesOptions(): each categorization. **This is available only for English categories.**. :attr int limit: (optional) Maximum number of categories to return. :attr str model: (optional) Enter a [custom - model](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-customizing) + model](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing) ID to override the standard categories model. The custom categories experimental feature will be retired on 19 December 2019. On that date, deployed custom categories models will no longer be accessible in @@ -740,7 +740,7 @@ def __init__(self, categories.**. :param int limit: (optional) Maximum number of categories to return. :param str model: (optional) Enter a [custom - model](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-customizing) + model](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing) ID to override the standard categories model. The custom categories experimental feature will be retired on 19 December 2019. On that date, deployed custom categories models will no longer be @@ -873,7 +873,7 @@ class CategoriesResult(): :attr str label: (optional) The path to the category through the 5-level taxonomy hierarchy. For the complete list of categories, see the [Categories - hierarchy](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-categories#categories-hierarchy) + hierarchy](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-categories#categories-hierarchy) documentation. :attr float score: (optional) Confidence score for the category classification. Higher values indicate greater confidence. @@ -892,7 +892,7 @@ def __init__(self, :param str label: (optional) The path to the category through the 5-level taxonomy hierarchy. For the complete list of categories, see the [Categories - hierarchy](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-categories#categories-hierarchy) + hierarchy](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-categories#categories-hierarchy) documentation. :param float score: (optional) Confidence score for the category classification. Higher values indicate greater confidence. @@ -967,7 +967,8 @@ class CategoriesResultExplanation(): followed by phrases that were less and less impactful. """ - def __init__(self, *, + def __init__(self, + *, relevant_text: List['CategoriesRelevantText'] = None) -> None: """ Initialize a CategoriesResultExplanation object. @@ -1462,7 +1463,9 @@ class EmotionOptions(): target string that is found in the document. """ - def __init__(self, *, document: bool = None, + def __init__(self, + *, + document: bool = None, targets: List[str] = None) -> None: """ Initialize a EmotionOptions object. @@ -1712,7 +1715,7 @@ class EntitiesOptions(): """ Identifies people, cities, organizations, and other entities in the content. See [Entity types and - subtypes](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-entity-types). + subtypes](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-entity-types). Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, Russian, Spanish, Swedish. Arabic, Chinese, and Dutch are supported only through custom models. @@ -1721,7 +1724,7 @@ class EntitiesOptions(): :attr bool mentions: (optional) Set this to `true` to return locations of entity mentions. :attr str model: (optional) Enter a [custom - model](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-customizing) + model](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing) ID to override the standard entity detection model. :attr bool sentiment: (optional) Set this to `true` to return sentiment information for detected entities. @@ -1743,7 +1746,7 @@ def __init__(self, :param bool mentions: (optional) Set this to `true` to return locations of entity mentions. :param str model: (optional) Enter a [custom - model](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-customizing) + model](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing) ID to override the standard entity detection model. :param bool sentiment: (optional) Set this to `true` to return sentiment information for detected entities. @@ -2131,7 +2134,7 @@ class Features(): Supported languages: English. :attr EntitiesOptions entities: (optional) Identifies people, cities, organizations, and other entities in the content. See [Entity types and - subtypes](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-entity-types). + subtypes](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-entity-types). Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, Russian, Spanish, Swedish. Arabic, Chinese, and Dutch are supported only through custom models. @@ -2146,7 +2149,7 @@ class Features(): related and identifies the type of relation. For example, an `awardedTo` relation might connect the entities "Nobel Prize" and "Albert Einstein". See [Relation - types](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-relations). + types](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-relations). Supported languages: Arabic, English, German, Japanese, Korean, Spanish. Chinese, Dutch, French, Italian, and Portuguese custom models are also supported. @@ -2195,7 +2198,7 @@ def __init__(self, Supported languages: English. :param EntitiesOptions entities: (optional) Identifies people, cities, organizations, and other entities in the content. See [Entity types and - subtypes](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-entity-types). + subtypes](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-entity-types). Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, Russian, Spanish, Swedish. Arabic, Chinese, and Dutch are supported only through custom models. @@ -2210,7 +2213,7 @@ def __init__(self, are related and identifies the type of relation. For example, an `awardedTo` relation might connect the entities "Nobel Prize" and "Albert Einstein". See [Relation - types](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-relations). + types](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-relations). Supported languages: Arabic, English, German, Japanese, Korean, Spanish. Chinese, Dutch, French, Italian, and Portuguese custom models are also supported. @@ -2976,12 +2979,12 @@ class RelationsOptions(): Recognizes when two entities are related and identifies the type of relation. For example, an `awardedTo` relation might connect the entities "Nobel Prize" and "Albert Einstein". See [Relation - types](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-relations). + types](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-relations). Supported languages: Arabic, English, German, Japanese, Korean, Spanish. Chinese, Dutch, French, Italian, and Portuguese custom models are also supported. :attr str model: (optional) Enter a [custom - model](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-customizing) + model](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing) ID to override the default model. """ @@ -2990,7 +2993,7 @@ def __init__(self, *, model: str = None) -> None: Initialize a RelationsOptions object. :param str model: (optional) Enter a [custom - model](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-customizing) + model](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing) ID to override the default model. """ self.model = model @@ -3831,7 +3834,9 @@ class SentimentOptions(): target string that is found in the document. """ - def __init__(self, *, document: bool = None, + def __init__(self, + *, + document: bool = None, targets: List[str] = None) -> None: """ Initialize a SentimentOptions object. @@ -4053,7 +4058,9 @@ class SyntaxOptionsTokens(): speech for each token. """ - def __init__(self, *, lemma: bool = None, + def __init__(self, + *, + lemma: bool = None, part_of_speech: bool = None) -> None: """ Initialize a SyntaxOptionsTokens object. @@ -4197,7 +4204,9 @@ class TargetedEmotionResults(): :attr EmotionScores emotion: (optional) The emotion results for the target. """ - def __init__(self, *, text: str = None, + def __init__(self, + *, + text: str = None, emotion: 'EmotionScores' = None) -> None: """ Initialize a TargetedEmotionResults object. diff --git a/ibm_watson/personality_insights_v3.py b/ibm_watson/personality_insights_v3.py index f04105bc4..7ba3c2986 100644 --- a/ibm_watson/personality_insights_v3.py +++ b/ibm_watson/personality_insights_v3.py @@ -507,9 +507,9 @@ class ConsumptionPreferencesCategory(): inferred from the input text for the individual preferences of the category. """ - def __init__(self, consumption_preference_category_id: str, name: str, - consumption_preferences: List['ConsumptionPreferences'] - ) -> None: + def __init__( + self, consumption_preference_category_id: str, name: str, + consumption_preferences: List['ConsumptionPreferences']) -> None: """ Initialize a ConsumptionPreferencesCategory object. @@ -903,18 +903,19 @@ class Profile(): no warnings. """ - def __init__(self, - processed_language: str, - word_count: int, - personality: List['Trait'], - needs: List['Trait'], - values: List['Trait'], - warnings: List['Warning'], - *, - word_count_message: str = None, - behavior: List['Behavior'] = None, - consumption_preferences: List[ - 'ConsumptionPreferencesCategory'] = None) -> None: + def __init__( + self, + processed_language: str, + word_count: int, + personality: List['Trait'], + needs: List['Trait'], + values: List['Trait'], + warnings: List['Warning'], + *, + word_count_message: str = None, + behavior: List['Behavior'] = None, + consumption_preferences: List['ConsumptionPreferencesCategory'] = None + ) -> None: """ Initialize a Profile object. diff --git a/ibm_watson/text_to_speech_adapter_v1.py b/ibm_watson/text_to_speech_adapter_v1.py index 4deab9ab9..899b84e28 100644 --- a/ibm_watson/text_to_speech_adapter_v1.py +++ b/ibm_watson/text_to_speech_adapter_v1.py @@ -41,25 +41,25 @@ def synthesize_using_websocket(self, :param str text: Provides the text that is to be synthesized. The client can pass plain text or text that is annotated with the Speech Synthesis Markup Language (SSML). For more - information, see [Specifying input text](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-usingHTTP#input). + information, see [Specifying input text](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-usingHTTP#input). SSML input can also include the element; - see [Specifying an SSML mark](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-timing#mark). + see [Specifying an SSML mark](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-timing#mark). The client can pass a maximum of 5 KB of text with the request. :param SynthesizeCallback synthesize_callback: The callback method for the websocket. :param str accept: Specifies the requested format (MIME type) of the audio. For more information, see [Specifying - an audio format](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-usingHTTP#format). In addition to the + an audio format](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-usingHTTP#format). In addition to the supported specifications, you can use */* to specify the default audio format, audio/ogg;codecs=opus. :param str voice: The voice to use for synthesis. :param list[str] timings: Specifies that the service is to return word timing information for all strings of the input text. The service returns the start and end time of each string of the input. Specify words as the lone element of the array to request word timings. Specify an empty array or omit the parameter to receive no word timings. For - more information, see [Obtaining word timings](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-timing#timing). + more information, see [Obtaining word timings](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-timing#timing). Not supported for Japanese input text. :param str customization_id: Specifies the globally unique identifier (GUID) for a custom voice model that is to be used for the synthesis. A custom voice model is guaranteed to work only if it matches the language of the voice that is used for the synthesis. If you include a customization ID, you must call the method with the service credentials of the custom model's owner. Omit the parameter to use the specified voice with no customization. For more information, see [Understanding customization] - (https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customIntro#customIntro). + (https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customIntro#customIntro). :param str http_proxy_host: http proxy host name. :param str http_proxy_port: http proxy port. If not set, set to 80. :param dict headers: A `dict` containing the request headers diff --git a/ibm_watson/text_to_speech_v1.py b/ibm_watson/text_to_speech_v1.py index 616918c3e..7dd168947 100644 --- a/ibm_watson/text_to_speech_v1.py +++ b/ibm_watson/text_to_speech_v1.py @@ -27,7 +27,8 @@ or more words that, when combined, sound like the word. A phonetic translation is based on the SSML phoneme format for representing a word. You can specify a phonetic translation in standard International Phonetic Alphabet (IPA) representation or in the proprietary IBM -Symbolic Phonetic Representation (SPR). +Symbolic Phonetic Representation (SPR). The Arabic, Chinese, Dutch, and Korean languages +support only IPA. """ import json @@ -104,7 +105,10 @@ def list_voices(self, **kwargs) -> 'DetailedResponse': response = self.send(request) return response - def get_voice(self, voice: str, *, customization_id: str = None, + def get_voice(self, + voice: str, + *, + customization_id: str = None, **kwargs) -> 'DetailedResponse': """ Get a voice. @@ -231,10 +235,10 @@ def synthesize(self, :param str voice: (optional) The voice to use for synthesis. :param str customization_id: (optional) The customization ID (GUID) of a custom voice model to use for the synthesis. If a custom voice model is - specified, it is guaranteed to work only if it matches the language of the - indicated voice. You must make the request with credentials for the - instance of the service that owns the custom model. Omit the parameter to - use the specified voice with no customization. + specified, it works only if it matches the language of the indicated voice. + You must make the request with credentials for the instance of the service + that owns the custom model. Omit the parameter to use the specified voice + with no customization. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse @@ -283,8 +287,7 @@ def get_pronunciation(self, pronunciation for a specific format. You can also request the pronunciation for a specific voice to see the default translation for the language of that voice or for a specific custom voice model to see the translation for that voice model. - **Note:** This method is currently a beta release. The method does not support the - Arabic, Chinese, and Dutch languages. + **Note:** This method is currently a beta release. **See also:** [Querying a word from a language](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordsQueryLanguage). @@ -293,8 +296,9 @@ def get_pronunciation(self, the pronunciation is to be returned. All voices for the same language (for example, `en-US`) return the same translation. :param str format: (optional) The phoneme format in which to return the - pronunciation. Omit the parameter to obtain the pronunciation in the - default format. + pronunciation. The Arabic, Chinese, Dutch, and Korean languages support + only IPA. Omit the parameter to obtain the pronunciation in the default + format. :param str customization_id: (optional) The customization ID (GUID) of a custom voice model for which the pronunciation is to be returned. The language of a specified custom model must match the language of the @@ -352,14 +356,16 @@ def create_voice_model(self, model. You can optionally specify the language and a description for the new model. The model is owned by the instance of the service whose credentials are used to create it. - **Note:** This method is currently a beta release. The service does not support - voice model customization for the Arabic, Chinese, and Dutch languages. + **Note:** This method is currently a beta release. **See also:** [Creating a custom model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsCreate). :param str name: The name of the new custom voice model. :param str language: (optional) The language of the new custom voice model. - Omit the parameter to use the the default language, `en-US`. + You create a custom voice model for a specific language, not for a specific + voice. A custom model can be used with any voice, standard or neural, for + its specified language. Omit the parameter to use the the default language, + `en-US`. :param str description: (optional) A description of the new custom voice model. Specifying a description is recommended. :param dict headers: A `dict` containing the request headers @@ -389,7 +395,9 @@ def create_voice_model(self, response = self.send(request) return response - def list_voice_models(self, *, language: str = None, + def list_voice_models(self, + *, + language: str = None, **kwargs) -> 'DetailedResponse': """ List custom models. @@ -739,8 +747,9 @@ def add_word(self, :param str translation: The phonetic or sounds-like translation for the word. A phonetic translation is based on the SSML format for representing the phonetic string of a word either as an IPA translation or as an IBM SPR - translation. A sounds-like is one or more words that, when combined, sound - like the word. + translation. The Arabic, Chinese, Dutch, and Korean languages support only + IPA. A sounds-like is one or more words that, when combined, sound like the + word. :param str part_of_speech: (optional) **Japanese only.** The part of speech for the word. The service uses the value to produce the correct intonation for the word. You can create only a single entry, with or without a single @@ -920,18 +929,24 @@ class Voice(Enum): """ The voice for which information is to be returned. """ + AR_AR_OMARVOICE = 'ar-AR_OmarVoice' DE_DE_BIRGITVOICE = 'de-DE_BirgitVoice' DE_DE_BIRGITV3VOICE = 'de-DE_BirgitV3Voice' DE_DE_DIETERVOICE = 'de-DE_DieterVoice' DE_DE_DIETERV3VOICE = 'de-DE_DieterV3Voice' + DE_DE_ERIKAV3VOICE = 'de-DE_ErikaV3Voice' EN_GB_KATEVOICE = 'en-GB_KateVoice' EN_GB_KATEV3VOICE = 'en-GB_KateV3Voice' EN_US_ALLISONVOICE = 'en-US_AllisonVoice' EN_US_ALLISONV3VOICE = 'en-US_AllisonV3Voice' + EN_US_EMILYV3VOICE = 'en-US_EmilyV3Voice' + EN_US_HENRYV3VOICE = 'en-US_HenryV3Voice' + EN_US_KEVINV3VOICE = 'en-US_KevinV3Voice' EN_US_LISAVOICE = 'en-US_LisaVoice' EN_US_LISAV3VOICE = 'en-US_LisaV3Voice' EN_US_MICHAELVOICE = 'en-US_MichaelVoice' EN_US_MICHAELV3VOICE = 'en-US_MichaelV3Voice' + EN_US_OLIVIAV3VOICE = 'en-US_OliviaV3Voice' ES_ES_ENRIQUEVOICE = 'es-ES_EnriqueVoice' ES_ES_ENRIQUEV3VOICE = 'es-ES_EnriqueV3Voice' ES_ES_LAURAVOICE = 'es-ES_LauraVoice' @@ -946,8 +961,15 @@ class Voice(Enum): IT_IT_FRANCESCAV3VOICE = 'it-IT_FrancescaV3Voice' JA_JP_EMIVOICE = 'ja-JP_EmiVoice' JA_JP_EMIV3VOICE = 'ja-JP_EmiV3Voice' + KO_KR_YOUNGMIVOICE = 'ko-KR_YoungmiVoice' + KO_KR_YUNAVOICE = 'ko-KR_YunaVoice' + NL_NL_EMMAVOICE = 'nl-NL_EmmaVoice' + NL_NL_LIAMVOICE = 'nl-NL_LiamVoice' PT_BR_ISABELAVOICE = 'pt-BR_IsabelaVoice' PT_BR_ISABELAV3VOICE = 'pt-BR_IsabelaV3Voice' + ZH_CN_LINAVOICE = 'zh-CN_LiNaVoice' + ZH_CN_WANGWEIVOICE = 'zh-CN_WangWeiVoice' + ZH_CN_ZHANGJINGVOICE = 'zh-CN_ZhangJingVoice' class SynthesizeEnums(object): @@ -982,14 +1004,19 @@ class Voice(Enum): DE_DE_BIRGITV3VOICE = 'de-DE_BirgitV3Voice' DE_DE_DIETERVOICE = 'de-DE_DieterVoice' DE_DE_DIETERV3VOICE = 'de-DE_DieterV3Voice' + DE_DE_ERIKAV3VOICE = 'de-DE_ErikaV3Voice' EN_GB_KATEVOICE = 'en-GB_KateVoice' EN_GB_KATEV3VOICE = 'en-GB_KateV3Voice' EN_US_ALLISONVOICE = 'en-US_AllisonVoice' EN_US_ALLISONV3VOICE = 'en-US_AllisonV3Voice' + EN_US_EMILYV3VOICE = 'en-US_EmilyV3Voice' + EN_US_HENRYV3VOICE = 'en-US_HenryV3Voice' + EN_US_KEVINV3VOICE = 'en-US_KevinV3Voice' EN_US_LISAVOICE = 'en-US_LisaVoice' EN_US_LISAV3VOICE = 'en-US_LisaV3Voice' EN_US_MICHAELVOICE = 'en-US_MichaelVoice' EN_US_MICHAELV3VOICE = 'en-US_MichaelV3Voice' + EN_US_OLIVIAV3VOICE = 'en-US_OliviaV3Voice' ES_ES_ENRIQUEVOICE = 'es-ES_EnriqueVoice' ES_ES_ENRIQUEV3VOICE = 'es-ES_EnriqueV3Voice' ES_ES_LAURAVOICE = 'es-ES_LauraVoice' @@ -1004,6 +1031,8 @@ class Voice(Enum): IT_IT_FRANCESCAV3VOICE = 'it-IT_FrancescaV3Voice' JA_JP_EMIVOICE = 'ja-JP_EmiVoice' JA_JP_EMIV3VOICE = 'ja-JP_EmiV3Voice' + KO_KR_YOUNGMIVOICE = 'ko-KR_YoungmiVoice' + KO_KR_YUNAVOICE = 'ko-KR_YunaVoice' NL_NL_EMMAVOICE = 'nl-NL_EmmaVoice' NL_NL_LIAMVOICE = 'nl-NL_LiamVoice' PT_BR_ISABELAVOICE = 'pt-BR_IsabelaVoice' @@ -1021,18 +1050,24 @@ class Voice(Enum): All voices for the same language (for example, `en-US`) return the same translation. """ + AR_AR_OMARVOICE = 'ar-AR_OmarVoice' DE_DE_BIRGITVOICE = 'de-DE_BirgitVoice' DE_DE_BIRGITV3VOICE = 'de-DE_BirgitV3Voice' DE_DE_DIETERVOICE = 'de-DE_DieterVoice' DE_DE_DIETERV3VOICE = 'de-DE_DieterV3Voice' + DE_DE_ERIKAV3VOICE = 'de-DE_ErikaV3Voice' EN_GB_KATEVOICE = 'en-GB_KateVoice' EN_GB_KATEV3VOICE = 'en-GB_KateV3Voice' EN_US_ALLISONVOICE = 'en-US_AllisonVoice' EN_US_ALLISONV3VOICE = 'en-US_AllisonV3Voice' + EN_US_EMILYV3VOICE = 'en-US_EmilyV3Voice' + EN_US_HENRYV3VOICE = 'en-US_HenryV3Voice' + EN_US_KEVINV3VOICE = 'en-US_KevinV3Voice' EN_US_LISAVOICE = 'en-US_LisaVoice' EN_US_LISAV3VOICE = 'en-US_LisaV3Voice' EN_US_MICHAELVOICE = 'en-US_MichaelVoice' EN_US_MICHAELV3VOICE = 'en-US_MichaelV3Voice' + EN_US_OLIVIAV3VOICE = 'en-US_OliviaV3Voice' ES_ES_ENRIQUEVOICE = 'es-ES_EnriqueVoice' ES_ES_ENRIQUEV3VOICE = 'es-ES_EnriqueV3Voice' ES_ES_LAURAVOICE = 'es-ES_LauraVoice' @@ -1047,13 +1082,21 @@ class Voice(Enum): IT_IT_FRANCESCAV3VOICE = 'it-IT_FrancescaV3Voice' JA_JP_EMIVOICE = 'ja-JP_EmiVoice' JA_JP_EMIV3VOICE = 'ja-JP_EmiV3Voice' + KO_KR_YOUNGMIVOICE = 'ko-KR_YoungmiVoice' + KO_KR_YUNAVOICE = 'ko-KR_YunaVoice' + NL_NL_EMMAVOICE = 'nl-NL_EmmaVoice' + NL_NL_LIAMVOICE = 'nl-NL_LiamVoice' PT_BR_ISABELAVOICE = 'pt-BR_IsabelaVoice' PT_BR_ISABELAV3VOICE = 'pt-BR_IsabelaV3Voice' + ZH_CN_LINAVOICE = 'zh-CN_LiNaVoice' + ZH_CN_WANGWEIVOICE = 'zh-CN_WangWeiVoice' + ZH_CN_ZHANGJINGVOICE = 'zh-CN_ZhangJingVoice' class Format(Enum): """ - The phoneme format in which to return the pronunciation. Omit the parameter to - obtain the pronunciation in the default format. + The phoneme format in which to return the pronunciation. The Arabic, Chinese, + Dutch, and Korean languages support only IPA. Omit the parameter to obtain the + pronunciation in the default format. """ IBM = 'ibm' IPA = 'ipa' @@ -1067,6 +1110,7 @@ class Language(Enum): credentials are to be returned. Omit the parameter to see all custom voice models that are owned by the requester. """ + AR_AR = 'ar-AR' DE_DE = 'de-DE' EN_GB = 'en-GB' EN_US = 'en-US' @@ -1076,7 +1120,10 @@ class Language(Enum): FR_FR = 'fr-FR' IT_IT = 'it-IT' JA_JP = 'ja-JP' + KO_KR = 'ko-KR' + NL_NL = 'nl-NL' PT_BR = 'pt-BR' + ZH_CN = 'zh-CN' ############################################################################## @@ -1242,8 +1289,9 @@ class Translation(): :attr str translation: The phonetic or sounds-like translation for the word. A phonetic translation is based on the SSML format for representing the phonetic - string of a word either as an IPA translation or as an IBM SPR translation. A - sounds-like is one or more words that, when combined, sound like the word. + string of a word either as an IPA translation or as an IBM SPR translation. The + Arabic, Chinese, Dutch, and Korean languages support only IPA. A sounds-like is + one or more words that, when combined, sound like the word. :attr str part_of_speech: (optional) **Japanese only.** The part of speech for the word. The service uses the value to produce the correct intonation for the word. You can create only a single entry, with or without a single part of @@ -1259,8 +1307,9 @@ def __init__(self, translation: str, *, part_of_speech: str = None) -> None: :param str translation: The phonetic or sounds-like translation for the word. A phonetic translation is based on the SSML format for representing the phonetic string of a word either as an IPA translation or as an IBM SPR - translation. A sounds-like is one or more words that, when combined, sound - like the word. + translation. The Arabic, Chinese, Dutch, and Korean languages support only + IPA. A sounds-like is one or more words that, when combined, sound like the + word. :param str part_of_speech: (optional) **Japanese only.** The part of speech for the word. The service uses the value to produce the correct intonation for the word. You can create only a single entry, with or without a single @@ -1814,12 +1863,14 @@ class Word(): """ Information about a word for the custom voice model. - :attr str word: The word for the custom voice model. + :attr str word: The word for the custom voice model. The maximum length of a + word is 49 characters. :attr str translation: The phonetic or sounds-like translation for the word. A phonetic translation is based on the SSML format for representing the phonetic - string of a word either as an IPA or IBM SPR translation. A sounds-like - translation consists of one or more words that, when combined, sound like the - word. + string of a word either as an IPA or IBM SPR translation. The Arabic, Chinese, + Dutch, and Korean languages support only IPA. A sounds-like translation consists + of one or more words that, when combined, sound like the word. The maximum + length of a translation is 499 characters. :attr str part_of_speech: (optional) **Japanese only.** The part of speech for the word. The service uses the value to produce the correct intonation for the word. You can create only a single entry, with or without a single part of @@ -1836,12 +1887,14 @@ def __init__(self, """ Initialize a Word object. - :param str word: The word for the custom voice model. + :param str word: The word for the custom voice model. The maximum length of + a word is 49 characters. :param str translation: The phonetic or sounds-like translation for the word. A phonetic translation is based on the SSML format for representing - the phonetic string of a word either as an IPA or IBM SPR translation. A + the phonetic string of a word either as an IPA or IBM SPR translation. The + Arabic, Chinese, Dutch, and Korean languages support only IPA. A sounds-like translation consists of one or more words that, when combined, - sound like the word. + sound like the word. The maximum length of a translation is 499 characters. :param str part_of_speech: (optional) **Japanese only.** The part of speech for the word. The service uses the value to produce the correct intonation for the word. You can create only a single entry, with or without a single diff --git a/ibm_watson/visual_recognition_v3.py b/ibm_watson/visual_recognition_v3.py index 84f904a69..524daef6b 100644 --- a/ibm_watson/visual_recognition_v3.py +++ b/ibm_watson/visual_recognition_v3.py @@ -279,7 +279,9 @@ def create_classifier(self, response = self.send(request) return response - def list_classifiers(self, *, verbose: bool = None, + def list_classifiers(self, + *, + verbose: bool = None, **kwargs) -> 'DetailedResponse': """ Retrieve a list of classifiers. @@ -666,7 +668,10 @@ class ClassResult(): identified. """ - def __init__(self, class_: str, score: float, *, + def __init__(self, + class_: str, + score: float, + *, type_hierarchy: str = None) -> None: """ Initialize a ClassResult object. diff --git a/ibm_watson/visual_recognition_v4.py b/ibm_watson/visual_recognition_v4.py index 8c320eddd..6711750cd 100644 --- a/ibm_watson/visual_recognition_v4.py +++ b/ibm_watson/visual_recognition_v4.py @@ -137,10 +137,11 @@ def analyze(self, params = {'version': self.version} form_data = [] - collection_ids = self._convert_list(collection_ids) - form_data.append(('collection_ids', (None, collection_ids, 'text/plain'))) - features = self._convert_list(features) - form_data.append(('features', (None, features, 'text/plain'))) + for item in collection_ids: + form_data.append( + ('collection_ids', (None, item, 'application/json'))) + for item in features: + form_data.append(('features', (None, item, 'application/json'))) if images_file: for item in images_file: form_data.append(('images_file', (item.filename, item.data, @@ -148,7 +149,8 @@ def analyze(self, 'application/octet-stream'))) if image_url: for item in image_url: - form_data.append(('image_url', (None, item, 'text/plain'))) + form_data.append( + ('image_url', (None, item, 'application/json'))) if threshold: threshold = str(threshold) form_data.append(('threshold', (None, threshold, 'text/plain'))) @@ -1371,7 +1373,8 @@ class DetectedObjects(): identified objects. """ - def __init__(self, *, + def __init__(self, + *, collections: List['CollectionObjects'] = None) -> None: """ Initialize a DetectedObjects object. @@ -2121,7 +2124,9 @@ class ImageSummary(): (UTC) that the image was most recently updated. """ - def __init__(self, *, image_id: str = None, + def __init__(self, + *, + image_id: str = None, updated: datetime = None) -> None: """ Initialize a ImageSummary object. @@ -2707,7 +2712,9 @@ class TrainingDataObject(): around the object. """ - def __init__(self, *, object: str = None, + def __init__(self, + *, + object: str = None, location: 'Location' = None) -> None: """ Initialize a TrainingDataObject object. @@ -3137,19 +3144,19 @@ class UpdateObjectMetadata(): :attr str object: The updated name of the object. The name can contain alphanumeric, underscore, hyphen, space, and dot characters. It cannot begin with the reserved prefix `sys-`. - :attr int count: Number of bounding boxes in the collection with the updated - object name. + :attr int count: (optional) Number of bounding boxes in the collection with the + updated object name. """ - def __init__(self, object: str, count: int) -> None: + def __init__(self, object: str, *, count: int = None) -> None: """ Initialize a UpdateObjectMetadata object. :param str object: The updated name of the object. The name can contain alphanumeric, underscore, hyphen, space, and dot characters. It cannot begin with the reserved prefix `sys-`. - :param int count: Number of bounding boxes in the collection with the - updated object name. + :param int count: (optional) Number of bounding boxes in the collection + with the updated object name. """ self.object = object self.count = count @@ -3172,10 +3179,6 @@ def from_dict(cls, _dict: Dict) -> 'UpdateObjectMetadata': ) if 'count' in _dict: args['count'] = _dict.get('count') - else: - raise ValueError( - 'Required property \'count\' not present in UpdateObjectMetadata JSON' - ) return cls(**args) @classmethod @@ -3220,7 +3223,10 @@ class Warning(): :attr str more_info: (optional) A URL for more information about the solution. """ - def __init__(self, code: str, message: str, *, + def __init__(self, + code: str, + message: str, + *, more_info: str = None) -> None: """ Initialize a Warning object. From 46e831801efec3a9124305632f0469b1adf6c804 Mon Sep 17 00:00:00 2001 From: Mamoon Raja Date: Thu, 16 Apr 2020 10:05:23 -0400 Subject: [PATCH 05/10] test: add tests for new updates and update formatting in tests --- .../test_language_translator_v3.py | 3 + test/unit/test_assistant_v1.py | 1170 +++++---------- test/unit/test_assistant_v2.py | 67 +- test/unit/test_compare_comply_v1.py | 178 +-- test/unit/test_discovery_v1.py | 1267 ++++++----------- test/unit/test_discovery_v2.py | 274 ++-- test/unit/test_language_translator_v3.py | 178 +-- .../test_natural_language_classifier_v1.py | 106 +- .../test_natural_language_understanding_v1.py | 94 +- test/unit/test_personality_insights_v3.py | 17 +- test/unit/test_speech_to_text_v1.py | 716 +++++----- test/unit/test_text_to_speech_v1.py | 285 ++-- test/unit/test_tone_analyzer_v3.py | 37 +- test/unit/test_visual_recognition_v3.py | 107 +- test/unit/test_visual_recognition_v4.py | 298 ++-- 15 files changed, 1900 insertions(+), 2897 deletions(-) diff --git a/test/integration/test_language_translator_v3.py b/test/integration/test_language_translator_v3.py index 5e0b6db04..b44ece2a7 100644 --- a/test/integration/test_language_translator_v3.py +++ b/test/integration/test_language_translator_v3.py @@ -19,6 +19,9 @@ def test_translate(self): translation = self.language_translator.translate( text='Hello', model_id='en-es').get_result() assert translation is not None + translation = self.language_translator.translate( + text='Hello, how are you?', target='es').get_result() + assert translation is not None def test_document_translation(self): with open(join(dirname(__file__), '../../resources/hello_world.txt'), diff --git a/test/unit/test_assistant_v1.py b/test/unit/test_assistant_v1.py index c3fbcabf0..6adccb3fb 100644 --- a/test/unit/test_assistant_v1.py +++ b/test/unit/test_assistant_v1.py @@ -29,7 +29,6 @@ ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for message #----------------------------------------------------------------------------- @@ -75,16 +74,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.message(**body) return output @@ -92,25 +91,7 @@ def call_service(self, body): def construct_full_body(self): body = dict() body['workspace_id'] = "string1" - body.update({ - "input": - MessageInput._from_dict(json.loads("""{"text": "fake_text"}""") - ), - "intents": [], - "entities": [], - "alternate_intents": - True, - "context": - Context._from_dict( - json.loads( - """{"conversation_id": "fake_conversation_id", "system": {}, "metadata": {"deployment": "fake_deployment", "user_id": "fake_user_id"}}""" - )), - "output": - OutputData._from_dict( - json.loads( - """{"nodes_visited": [], "nodes_visited_details": [], "log_messages": [], "text": [], "generic": []}""" - )), - }) + body.update({"input": MessageInput._from_dict(json.loads("""{"text": "fake_text"}""")), "intents": [], "entities": [], "alternate_intents": True, "context": Context._from_dict(json.loads("""{"conversation_id": "fake_conversation_id", "system": {}, "metadata": {"deployment": "fake_deployment", "user_id": "fake_user_id"}}""")), "output": OutputData._from_dict(json.loads("""{"nodes_visited": [], "nodes_visited_details": [], "log_messages": [], "text": [], "generic": []}""")), }) body['nodes_visited_details'] = True return body @@ -130,7 +111,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_workspaces #----------------------------------------------------------------------------- @@ -175,16 +155,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.list_workspaces(**body) return output @@ -246,45 +226,23 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=201, - content_type='application/json') - + url, + body=json.dumps(response), + status=201, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.create_workspace(**body) return output def construct_full_body(self): body = dict() - body.update({ - "name": - "string1", - "description": - "string1", - "language": - "string1", - "metadata": { - "mock": "data" - }, - "learning_opt_out": - True, - "system_settings": - WorkspaceSystemSettings._from_dict( - json.loads( - """{"tooling": {"store_generic_responses": false}, "disambiguation": {"prompt": "fake_prompt", "none_of_the_above_prompt": "fake_none_of_the_above_prompt", "enabled": false, "sensitivity": "fake_sensitivity", "randomize": false, "max_suggestions": 15, "suggestion_text_policy": "fake_suggestion_text_policy"}, "system_entities": {"enabled": false}, "off_topic": {"enabled": false}}""" - )), - "intents": [], - "entities": [], - "dialog_nodes": [], - "counterexamples": [], - "webhooks": [], - }) + body.update({"name": "string1", "description": "string1", "language": "string1", "metadata": {"mock": "data"}, "learning_opt_out": True, "system_settings": WorkspaceSystemSettings._from_dict(json.loads("""{"tooling": {"store_generic_responses": false}, "disambiguation": {"prompt": "fake_prompt", "none_of_the_above_prompt": "fake_none_of_the_above_prompt", "enabled": false, "sensitivity": "fake_sensitivity", "randomize": false, "max_suggestions": 15, "suggestion_text_policy": "fake_suggestion_text_policy"}, "system_entities": {"enabled": false}, "off_topic": {"enabled": false}}""")), "intents": [], "entities": [], "dialog_nodes": [], "counterexamples": [], "webhooks": [], }) body['include_audit'] = True return body @@ -338,16 +296,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.get_workspace(**body) return output @@ -411,16 +369,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.update_workspace(**body) return output @@ -428,29 +386,7 @@ def call_service(self, body): def construct_full_body(self): body = dict() body['workspace_id'] = "string1" - body.update({ - "name": - "string1", - "description": - "string1", - "language": - "string1", - "metadata": { - "mock": "data" - }, - "learning_opt_out": - True, - "system_settings": - WorkspaceSystemSettings._from_dict( - json.loads( - """{"tooling": {"store_generic_responses": false}, "disambiguation": {"prompt": "fake_prompt", "none_of_the_above_prompt": "fake_none_of_the_above_prompt", "enabled": false, "sensitivity": "fake_sensitivity", "randomize": false, "max_suggestions": 15, "suggestion_text_policy": "fake_suggestion_text_policy"}, "system_entities": {"enabled": false}, "off_topic": {"enabled": false}}""" - )), - "intents": [], - "entities": [], - "dialog_nodes": [], - "counterexamples": [], - "webhooks": [], - }) + body.update({"name": "string1", "description": "string1", "language": "string1", "metadata": {"mock": "data"}, "learning_opt_out": True, "system_settings": WorkspaceSystemSettings._from_dict(json.loads("""{"tooling": {"store_generic_responses": false}, "disambiguation": {"prompt": "fake_prompt", "none_of_the_above_prompt": "fake_none_of_the_above_prompt", "enabled": false, "sensitivity": "fake_sensitivity", "randomize": false, "max_suggestions": 15, "suggestion_text_policy": "fake_suggestion_text_policy"}, "system_entities": {"enabled": false}, "off_topic": {"enabled": false}}""")), "intents": [], "entities": [], "dialog_nodes": [], "counterexamples": [], "webhooks": [], }) body['append'] = True body['include_audit'] = True return body @@ -506,16 +442,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.delete_workspace(**body) return output @@ -541,7 +477,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_intents #----------------------------------------------------------------------------- @@ -587,16 +522,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.list_intents(**body) return output @@ -662,16 +597,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=201, - content_type='application/json') - + url, + body=json.dumps(response), + status=201, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.create_intent(**body) return output @@ -679,22 +614,14 @@ def call_service(self, body): def construct_full_body(self): body = dict() body['workspace_id'] = "string1" - body.update({ - "intent": "string1", - "description": "string1", - "examples": [], - }) + body.update({"intent": "string1", "description": "string1", "examples": [], }) body['include_audit'] = True return body def construct_required_body(self): body = dict() body['workspace_id'] = "string1" - body.update({ - "intent": "string1", - "description": "string1", - "examples": [], - }) + body.update({"intent": "string1", "description": "string1", "examples": [], }) return body @@ -737,23 +664,22 @@ def test_get_intent_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/intents/{1}'.format( - body['workspace_id'], body['intent']) + endpoint = '/v1/workspaces/{0}/intents/{1}'.format(body['workspace_id'], body['intent']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.get_intent(**body) return output @@ -812,23 +738,22 @@ def test_update_intent_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/intents/{1}'.format( - body['workspace_id'], body['intent']) + endpoint = '/v1/workspaces/{0}/intents/{1}'.format(body['workspace_id'], body['intent']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.update_intent(**body) return output @@ -837,11 +762,7 @@ def construct_full_body(self): body = dict() body['workspace_id'] = "string1" body['intent'] = "string1" - body.update({ - "new_intent": "string1", - "new_description": "string1", - "new_examples": [], - }) + body.update({"new_intent": "string1", "new_description": "string1", "new_examples": [], }) body['append'] = True body['include_audit'] = True return body @@ -850,11 +771,7 @@ def construct_required_body(self): body = dict() body['workspace_id'] = "string1" body['intent'] = "string1" - body.update({ - "new_intent": "string1", - "new_description": "string1", - "new_examples": [], - }) + body.update({"new_intent": "string1", "new_description": "string1", "new_examples": [], }) return body @@ -897,23 +814,22 @@ def test_delete_intent_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/intents/{1}'.format( - body['workspace_id'], body['intent']) + endpoint = '/v1/workspaces/{0}/intents/{1}'.format(body['workspace_id'], body['intent']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.delete_intent(**body) return output @@ -941,7 +857,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_examples #----------------------------------------------------------------------------- @@ -981,23 +896,22 @@ def test_list_examples_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/intents/{1}/examples'.format( - body['workspace_id'], body['intent']) + endpoint = '/v1/workspaces/{0}/intents/{1}/examples'.format(body['workspace_id'], body['intent']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.list_examples(**body) return output @@ -1058,23 +972,22 @@ def test_create_example_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/intents/{1}/examples'.format( - body['workspace_id'], body['intent']) + endpoint = '/v1/workspaces/{0}/intents/{1}/examples'.format(body['workspace_id'], body['intent']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=201, - content_type='application/json') - + url, + body=json.dumps(response), + status=201, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.create_example(**body) return output @@ -1083,10 +996,7 @@ def construct_full_body(self): body = dict() body['workspace_id'] = "string1" body['intent'] = "string1" - body.update({ - "text": "string1", - "mentions": [], - }) + body.update({"text": "string1", "mentions": [], }) body['include_audit'] = True return body @@ -1094,10 +1004,7 @@ def construct_required_body(self): body = dict() body['workspace_id'] = "string1" body['intent'] = "string1" - body.update({ - "text": "string1", - "mentions": [], - }) + body.update({"text": "string1", "mentions": [], }) return body @@ -1140,23 +1047,22 @@ def test_get_example_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/intents/{1}/examples/{2}'.format( - body['workspace_id'], body['intent'], body['text']) + endpoint = '/v1/workspaces/{0}/intents/{1}/examples/{2}'.format(body['workspace_id'], body['intent'], body['text']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.get_example(**body) return output @@ -1216,23 +1122,22 @@ def test_update_example_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/intents/{1}/examples/{2}'.format( - body['workspace_id'], body['intent'], body['text']) + endpoint = '/v1/workspaces/{0}/intents/{1}/examples/{2}'.format(body['workspace_id'], body['intent'], body['text']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.update_example(**body) return output @@ -1242,10 +1147,7 @@ def construct_full_body(self): body['workspace_id'] = "string1" body['intent'] = "string1" body['text'] = "string1" - body.update({ - "new_text": "string1", - "new_mentions": [], - }) + body.update({"new_text": "string1", "new_mentions": [], }) body['include_audit'] = True return body @@ -1254,10 +1156,7 @@ def construct_required_body(self): body['workspace_id'] = "string1" body['intent'] = "string1" body['text'] = "string1" - body.update({ - "new_text": "string1", - "new_mentions": [], - }) + body.update({"new_text": "string1", "new_mentions": [], }) return body @@ -1300,23 +1199,22 @@ def test_delete_example_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/intents/{1}/examples/{2}'.format( - body['workspace_id'], body['intent'], body['text']) + endpoint = '/v1/workspaces/{0}/intents/{1}/examples/{2}'.format(body['workspace_id'], body['intent'], body['text']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.delete_example(**body) return output @@ -1346,7 +1244,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_counterexamples #----------------------------------------------------------------------------- @@ -1378,8 +1275,7 @@ def test_list_counterexamples_required_response(self): #-------------------------------------------------------- @responses.activate def test_list_counterexamples_empty(self): - check_empty_required_params( - self, fake_response_CounterexampleCollection_json) + check_empty_required_params(self, fake_response_CounterexampleCollection_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -1387,23 +1283,22 @@ def test_list_counterexamples_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/counterexamples'.format( - body['workspace_id']) + endpoint = '/v1/workspaces/{0}/counterexamples'.format(body['workspace_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.list_counterexamples(**body) return output @@ -1462,23 +1357,22 @@ def test_create_counterexample_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/counterexamples'.format( - body['workspace_id']) + endpoint = '/v1/workspaces/{0}/counterexamples'.format(body['workspace_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=201, - content_type='application/json') - + url, + body=json.dumps(response), + status=201, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.create_counterexample(**body) return output @@ -1486,18 +1380,14 @@ def call_service(self, body): def construct_full_body(self): body = dict() body['workspace_id'] = "string1" - body.update({ - "text": "string1", - }) + body.update({"text": "string1", }) body['include_audit'] = True return body def construct_required_body(self): body = dict() body['workspace_id'] = "string1" - body.update({ - "text": "string1", - }) + body.update({"text": "string1", }) return body @@ -1540,23 +1430,22 @@ def test_get_counterexample_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/counterexamples/{1}'.format( - body['workspace_id'], body['text']) + endpoint = '/v1/workspaces/{0}/counterexamples/{1}'.format(body['workspace_id'], body['text']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.get_counterexample(**body) return output @@ -1614,23 +1503,22 @@ def test_update_counterexample_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/counterexamples/{1}'.format( - body['workspace_id'], body['text']) + endpoint = '/v1/workspaces/{0}/counterexamples/{1}'.format(body['workspace_id'], body['text']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.update_counterexample(**body) return output @@ -1639,9 +1527,7 @@ def construct_full_body(self): body = dict() body['workspace_id'] = "string1" body['text'] = "string1" - body.update({ - "new_text": "string1", - }) + body.update({"new_text": "string1", }) body['include_audit'] = True return body @@ -1649,9 +1535,7 @@ def construct_required_body(self): body = dict() body['workspace_id'] = "string1" body['text'] = "string1" - body.update({ - "new_text": "string1", - }) + body.update({"new_text": "string1", }) return body @@ -1694,23 +1578,22 @@ def test_delete_counterexample_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/counterexamples/{1}'.format( - body['workspace_id'], body['text']) + endpoint = '/v1/workspaces/{0}/counterexamples/{1}'.format(body['workspace_id'], body['text']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.delete_counterexample(**body) return output @@ -1738,7 +1621,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_entities #----------------------------------------------------------------------------- @@ -1784,16 +1666,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.list_entities(**body) return output @@ -1859,16 +1741,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=201, - content_type='application/json') - + url, + body=json.dumps(response), + status=201, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.create_entity(**body) return output @@ -1876,30 +1758,14 @@ def call_service(self, body): def construct_full_body(self): body = dict() body['workspace_id'] = "string1" - body.update({ - "entity": "string1", - "description": "string1", - "metadata": { - "mock": "data" - }, - "fuzzy_match": True, - "values": [], - }) + body.update({"entity": "string1", "description": "string1", "metadata": {"mock": "data"}, "fuzzy_match": True, "values": [], }) body['include_audit'] = True return body def construct_required_body(self): body = dict() body['workspace_id'] = "string1" - body.update({ - "entity": "string1", - "description": "string1", - "metadata": { - "mock": "data" - }, - "fuzzy_match": True, - "values": [], - }) + body.update({"entity": "string1", "description": "string1", "metadata": {"mock": "data"}, "fuzzy_match": True, "values": [], }) return body @@ -1942,23 +1808,22 @@ def test_get_entity_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/entities/{1}'.format( - body['workspace_id'], body['entity']) + endpoint = '/v1/workspaces/{0}/entities/{1}'.format(body['workspace_id'], body['entity']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.get_entity(**body) return output @@ -2017,23 +1882,22 @@ def test_update_entity_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/entities/{1}'.format( - body['workspace_id'], body['entity']) + endpoint = '/v1/workspaces/{0}/entities/{1}'.format(body['workspace_id'], body['entity']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.update_entity(**body) return output @@ -2042,15 +1906,7 @@ def construct_full_body(self): body = dict() body['workspace_id'] = "string1" body['entity'] = "string1" - body.update({ - "new_entity": "string1", - "new_description": "string1", - "new_metadata": { - "mock": "data" - }, - "new_fuzzy_match": True, - "new_values": [], - }) + body.update({"new_entity": "string1", "new_description": "string1", "new_metadata": {"mock": "data"}, "new_fuzzy_match": True, "new_values": [], }) body['append'] = True body['include_audit'] = True return body @@ -2059,15 +1915,7 @@ def construct_required_body(self): body = dict() body['workspace_id'] = "string1" body['entity'] = "string1" - body.update({ - "new_entity": "string1", - "new_description": "string1", - "new_metadata": { - "mock": "data" - }, - "new_fuzzy_match": True, - "new_values": [], - }) + body.update({"new_entity": "string1", "new_description": "string1", "new_metadata": {"mock": "data"}, "new_fuzzy_match": True, "new_values": [], }) return body @@ -2110,23 +1958,22 @@ def test_delete_entity_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/entities/{1}'.format( - body['workspace_id'], body['entity']) + endpoint = '/v1/workspaces/{0}/entities/{1}'.format(body['workspace_id'], body['entity']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.delete_entity(**body) return output @@ -2154,7 +2001,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_mentions #----------------------------------------------------------------------------- @@ -2186,8 +2032,7 @@ def test_list_mentions_required_response(self): #-------------------------------------------------------- @responses.activate def test_list_mentions_empty(self): - check_empty_required_params(self, - fake_response_EntityMentionCollection_json) + check_empty_required_params(self, fake_response_EntityMentionCollection_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -2195,23 +2040,22 @@ def test_list_mentions_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/entities/{1}/mentions'.format( - body['workspace_id'], body['entity']) + endpoint = '/v1/workspaces/{0}/entities/{1}/mentions'.format(body['workspace_id'], body['entity']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.list_mentions(**body) return output @@ -2241,7 +2085,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_values #----------------------------------------------------------------------------- @@ -2281,23 +2124,22 @@ def test_list_values_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/entities/{1}/values'.format( - body['workspace_id'], body['entity']) + endpoint = '/v1/workspaces/{0}/entities/{1}/values'.format(body['workspace_id'], body['entity']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.list_values(**body) return output @@ -2359,23 +2201,22 @@ def test_create_value_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/entities/{1}/values'.format( - body['workspace_id'], body['entity']) + endpoint = '/v1/workspaces/{0}/entities/{1}/values'.format(body['workspace_id'], body['entity']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=201, - content_type='application/json') - + url, + body=json.dumps(response), + status=201, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.create_value(**body) return output @@ -2384,15 +2225,7 @@ def construct_full_body(self): body = dict() body['workspace_id'] = "string1" body['entity'] = "string1" - body.update({ - "value": "string1", - "metadata": { - "mock": "data" - }, - "type": "string1", - "synonyms": [], - "patterns": [], - }) + body.update({"value": "string1", "metadata": {"mock": "data"}, "type": "string1", "synonyms": [], "patterns": [], }) body['include_audit'] = True return body @@ -2400,15 +2233,7 @@ def construct_required_body(self): body = dict() body['workspace_id'] = "string1" body['entity'] = "string1" - body.update({ - "value": "string1", - "metadata": { - "mock": "data" - }, - "type": "string1", - "synonyms": [], - "patterns": [], - }) + body.update({"value": "string1", "metadata": {"mock": "data"}, "type": "string1", "synonyms": [], "patterns": [], }) return body @@ -2451,23 +2276,22 @@ def test_get_value_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/entities/{1}/values/{2}'.format( - body['workspace_id'], body['entity'], body['value']) + endpoint = '/v1/workspaces/{0}/entities/{1}/values/{2}'.format(body['workspace_id'], body['entity'], body['value']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.get_value(**body) return output @@ -2528,23 +2352,22 @@ def test_update_value_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/entities/{1}/values/{2}'.format( - body['workspace_id'], body['entity'], body['value']) + endpoint = '/v1/workspaces/{0}/entities/{1}/values/{2}'.format(body['workspace_id'], body['entity'], body['value']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.update_value(**body) return output @@ -2554,15 +2377,7 @@ def construct_full_body(self): body['workspace_id'] = "string1" body['entity'] = "string1" body['value'] = "string1" - body.update({ - "new_value": "string1", - "new_metadata": { - "mock": "data" - }, - "new_type": "string1", - "new_synonyms": [], - "new_patterns": [], - }) + body.update({"new_value": "string1", "new_metadata": {"mock": "data"}, "new_type": "string1", "new_synonyms": [], "new_patterns": [], }) body['append'] = True body['include_audit'] = True return body @@ -2572,15 +2387,7 @@ def construct_required_body(self): body['workspace_id'] = "string1" body['entity'] = "string1" body['value'] = "string1" - body.update({ - "new_value": "string1", - "new_metadata": { - "mock": "data" - }, - "new_type": "string1", - "new_synonyms": [], - "new_patterns": [], - }) + body.update({"new_value": "string1", "new_metadata": {"mock": "data"}, "new_type": "string1", "new_synonyms": [], "new_patterns": [], }) return body @@ -2623,23 +2430,22 @@ def test_delete_value_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/entities/{1}/values/{2}'.format( - body['workspace_id'], body['entity'], body['value']) + endpoint = '/v1/workspaces/{0}/entities/{1}/values/{2}'.format(body['workspace_id'], body['entity'], body['value']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.delete_value(**body) return output @@ -2669,7 +2475,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_synonyms #----------------------------------------------------------------------------- @@ -2709,23 +2514,22 @@ def test_list_synonyms_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/entities/{1}/values/{2}/synonyms'.format( - body['workspace_id'], body['entity'], body['value']) + endpoint = '/v1/workspaces/{0}/entities/{1}/values/{2}/synonyms'.format(body['workspace_id'], body['entity'], body['value']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.list_synonyms(**body) return output @@ -2788,23 +2592,22 @@ def test_create_synonym_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/entities/{1}/values/{2}/synonyms'.format( - body['workspace_id'], body['entity'], body['value']) + endpoint = '/v1/workspaces/{0}/entities/{1}/values/{2}/synonyms'.format(body['workspace_id'], body['entity'], body['value']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=201, - content_type='application/json') - + url, + body=json.dumps(response), + status=201, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.create_synonym(**body) return output @@ -2814,9 +2617,7 @@ def construct_full_body(self): body['workspace_id'] = "string1" body['entity'] = "string1" body['value'] = "string1" - body.update({ - "synonym": "string1", - }) + body.update({"synonym": "string1", }) body['include_audit'] = True return body @@ -2825,9 +2626,7 @@ def construct_required_body(self): body['workspace_id'] = "string1" body['entity'] = "string1" body['value'] = "string1" - body.update({ - "synonym": "string1", - }) + body.update({"synonym": "string1", }) return body @@ -2870,24 +2669,22 @@ def test_get_synonym_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/entities/{1}/values/{2}/synonyms/{3}'.format( - body['workspace_id'], body['entity'], body['value'], - body['synonym']) + endpoint = '/v1/workspaces/{0}/entities/{1}/values/{2}/synonyms/{3}'.format(body['workspace_id'], body['entity'], body['value'], body['synonym']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.get_synonym(**body) return output @@ -2949,24 +2746,22 @@ def test_update_synonym_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/entities/{1}/values/{2}/synonyms/{3}'.format( - body['workspace_id'], body['entity'], body['value'], - body['synonym']) + endpoint = '/v1/workspaces/{0}/entities/{1}/values/{2}/synonyms/{3}'.format(body['workspace_id'], body['entity'], body['value'], body['synonym']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.update_synonym(**body) return output @@ -2977,9 +2772,7 @@ def construct_full_body(self): body['entity'] = "string1" body['value'] = "string1" body['synonym'] = "string1" - body.update({ - "new_synonym": "string1", - }) + body.update({"new_synonym": "string1", }) body['include_audit'] = True return body @@ -2989,9 +2782,7 @@ def construct_required_body(self): body['entity'] = "string1" body['value'] = "string1" body['synonym'] = "string1" - body.update({ - "new_synonym": "string1", - }) + body.update({"new_synonym": "string1", }) return body @@ -3034,24 +2825,22 @@ def test_delete_synonym_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/entities/{1}/values/{2}/synonyms/{3}'.format( - body['workspace_id'], body['entity'], body['value'], - body['synonym']) + endpoint = '/v1/workspaces/{0}/entities/{1}/values/{2}/synonyms/{3}'.format(body['workspace_id'], body['entity'], body['value'], body['synonym']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.delete_synonym(**body) return output @@ -3083,7 +2872,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_dialog_nodes #----------------------------------------------------------------------------- @@ -3115,8 +2903,7 @@ def test_list_dialog_nodes_required_response(self): #-------------------------------------------------------- @responses.activate def test_list_dialog_nodes_empty(self): - check_empty_required_params(self, - fake_response_DialogNodeCollection_json) + check_empty_required_params(self, fake_response_DialogNodeCollection_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -3124,23 +2911,22 @@ def test_list_dialog_nodes_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/dialog_nodes'.format( - body['workspace_id']) + endpoint = '/v1/workspaces/{0}/dialog_nodes'.format(body['workspace_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.list_dialog_nodes(**body) return output @@ -3199,23 +2985,22 @@ def test_create_dialog_node_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/dialog_nodes'.format( - body['workspace_id']) + endpoint = '/v1/workspaces/{0}/dialog_nodes'.format(body['workspace_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=201, - content_type='application/json') - + url, + body=json.dumps(response), + status=201, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.create_dialog_node(**body) return output @@ -3223,106 +3008,14 @@ def call_service(self, body): def construct_full_body(self): body = dict() body['workspace_id'] = "string1" - body.update({ - "dialog_node": - "string1", - "description": - "string1", - "conditions": - "string1", - "parent": - "string1", - "previous_sibling": - "string1", - "output": - DialogNodeOutput._from_dict( - json.loads( - """{"generic": [], "modifiers": {"overwrite": false}}""" - )), - "context": { - "mock": "data" - }, - "metadata": { - "mock": "data" - }, - "next_step": - DialogNodeNextStep._from_dict( - json.loads( - """{"behavior": "fake_behavior", "dialog_node": "fake_dialog_node", "selector": "fake_selector"}""" - )), - "title": - "string1", - "type": - "string1", - "event_name": - "string1", - "variable": - "string1", - "actions": [], - "digress_in": - "string1", - "digress_out": - "string1", - "digress_out_slots": - "string1", - "user_label": - "string1", - "disambiguation_opt_out": - True, - }) + body.update({"dialog_node": "string1", "description": "string1", "conditions": "string1", "parent": "string1", "previous_sibling": "string1", "output": DialogNodeOutput._from_dict(json.loads("""{"generic": [], "modifiers": {"overwrite": false}}""")), "context": {"mock": "data"}, "metadata": {"mock": "data"}, "next_step": DialogNodeNextStep._from_dict(json.loads("""{"behavior": "fake_behavior", "dialog_node": "fake_dialog_node", "selector": "fake_selector"}""")), "title": "string1", "type": "string1", "event_name": "string1", "variable": "string1", "actions": [], "digress_in": "string1", "digress_out": "string1", "digress_out_slots": "string1", "user_label": "string1", "disambiguation_opt_out": True, }) body['include_audit'] = True return body def construct_required_body(self): body = dict() body['workspace_id'] = "string1" - body.update({ - "dialog_node": - "string1", - "description": - "string1", - "conditions": - "string1", - "parent": - "string1", - "previous_sibling": - "string1", - "output": - DialogNodeOutput._from_dict( - json.loads( - """{"generic": [], "modifiers": {"overwrite": false}}""" - )), - "context": { - "mock": "data" - }, - "metadata": { - "mock": "data" - }, - "next_step": - DialogNodeNextStep._from_dict( - json.loads( - """{"behavior": "fake_behavior", "dialog_node": "fake_dialog_node", "selector": "fake_selector"}""" - )), - "title": - "string1", - "type": - "string1", - "event_name": - "string1", - "variable": - "string1", - "actions": [], - "digress_in": - "string1", - "digress_out": - "string1", - "digress_out_slots": - "string1", - "user_label": - "string1", - "disambiguation_opt_out": - True, - }) + body.update({"dialog_node": "string1", "description": "string1", "conditions": "string1", "parent": "string1", "previous_sibling": "string1", "output": DialogNodeOutput._from_dict(json.loads("""{"generic": [], "modifiers": {"overwrite": false}}""")), "context": {"mock": "data"}, "metadata": {"mock": "data"}, "next_step": DialogNodeNextStep._from_dict(json.loads("""{"behavior": "fake_behavior", "dialog_node": "fake_dialog_node", "selector": "fake_selector"}""")), "title": "string1", "type": "string1", "event_name": "string1", "variable": "string1", "actions": [], "digress_in": "string1", "digress_out": "string1", "digress_out_slots": "string1", "user_label": "string1", "disambiguation_opt_out": True, }) return body @@ -3365,23 +3058,22 @@ def test_get_dialog_node_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/dialog_nodes/{1}'.format( - body['workspace_id'], body['dialog_node']) + endpoint = '/v1/workspaces/{0}/dialog_nodes/{1}'.format(body['workspace_id'], body['dialog_node']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.get_dialog_node(**body) return output @@ -3439,23 +3131,22 @@ def test_update_dialog_node_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/dialog_nodes/{1}'.format( - body['workspace_id'], body['dialog_node']) + endpoint = '/v1/workspaces/{0}/dialog_nodes/{1}'.format(body['workspace_id'], body['dialog_node']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.update_dialog_node(**body) return output @@ -3464,53 +3155,7 @@ def construct_full_body(self): body = dict() body['workspace_id'] = "string1" body['dialog_node'] = "string1" - body.update({ - "new_dialog_node": - "string1", - "new_description": - "string1", - "new_conditions": - "string1", - "new_parent": - "string1", - "new_previous_sibling": - "string1", - "new_output": - DialogNodeOutput._from_dict( - json.loads( - """{"generic": [], "modifiers": {"overwrite": false}}""" - )), - "new_context": { - "mock": "data" - }, - "new_metadata": { - "mock": "data" - }, - "new_next_step": - DialogNodeNextStep._from_dict( - json.loads( - """{"behavior": "fake_behavior", "dialog_node": "fake_dialog_node", "selector": "fake_selector"}""" - )), - "new_title": - "string1", - "new_type": - "string1", - "new_event_name": - "string1", - "new_variable": - "string1", - "new_actions": [], - "new_digress_in": - "string1", - "new_digress_out": - "string1", - "new_digress_out_slots": - "string1", - "new_user_label": - "string1", - "new_disambiguation_opt_out": - True, - }) + body.update({"new_dialog_node": "string1", "new_description": "string1", "new_conditions": "string1", "new_parent": "string1", "new_previous_sibling": "string1", "new_output": DialogNodeOutput._from_dict(json.loads("""{"generic": [], "modifiers": {"overwrite": false}}""")), "new_context": {"mock": "data"}, "new_metadata": {"mock": "data"}, "new_next_step": DialogNodeNextStep._from_dict(json.loads("""{"behavior": "fake_behavior", "dialog_node": "fake_dialog_node", "selector": "fake_selector"}""")), "new_title": "string1", "new_type": "string1", "new_event_name": "string1", "new_variable": "string1", "new_actions": [], "new_digress_in": "string1", "new_digress_out": "string1", "new_digress_out_slots": "string1", "new_user_label": "string1", "new_disambiguation_opt_out": True, }) body['include_audit'] = True return body @@ -3518,53 +3163,7 @@ def construct_required_body(self): body = dict() body['workspace_id'] = "string1" body['dialog_node'] = "string1" - body.update({ - "new_dialog_node": - "string1", - "new_description": - "string1", - "new_conditions": - "string1", - "new_parent": - "string1", - "new_previous_sibling": - "string1", - "new_output": - DialogNodeOutput._from_dict( - json.loads( - """{"generic": [], "modifiers": {"overwrite": false}}""" - )), - "new_context": { - "mock": "data" - }, - "new_metadata": { - "mock": "data" - }, - "new_next_step": - DialogNodeNextStep._from_dict( - json.loads( - """{"behavior": "fake_behavior", "dialog_node": "fake_dialog_node", "selector": "fake_selector"}""" - )), - "new_title": - "string1", - "new_type": - "string1", - "new_event_name": - "string1", - "new_variable": - "string1", - "new_actions": [], - "new_digress_in": - "string1", - "new_digress_out": - "string1", - "new_digress_out_slots": - "string1", - "new_user_label": - "string1", - "new_disambiguation_opt_out": - True, - }) + body.update({"new_dialog_node": "string1", "new_description": "string1", "new_conditions": "string1", "new_parent": "string1", "new_previous_sibling": "string1", "new_output": DialogNodeOutput._from_dict(json.loads("""{"generic": [], "modifiers": {"overwrite": false}}""")), "new_context": {"mock": "data"}, "new_metadata": {"mock": "data"}, "new_next_step": DialogNodeNextStep._from_dict(json.loads("""{"behavior": "fake_behavior", "dialog_node": "fake_dialog_node", "selector": "fake_selector"}""")), "new_title": "string1", "new_type": "string1", "new_event_name": "string1", "new_variable": "string1", "new_actions": [], "new_digress_in": "string1", "new_digress_out": "string1", "new_digress_out_slots": "string1", "new_user_label": "string1", "new_disambiguation_opt_out": True, }) return body @@ -3607,23 +3206,22 @@ def test_delete_dialog_node_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/workspaces/{0}/dialog_nodes/{1}'.format( - body['workspace_id'], body['dialog_node']) + endpoint = '/v1/workspaces/{0}/dialog_nodes/{1}'.format(body['workspace_id'], body['dialog_node']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.delete_dialog_node(**body) return output @@ -3651,7 +3249,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_logs #----------------------------------------------------------------------------- @@ -3697,16 +3294,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.list_logs(**body) return output @@ -3771,16 +3368,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.list_all_logs(**body) return output @@ -3809,7 +3406,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for delete_user_data #----------------------------------------------------------------------------- @@ -3855,16 +3451,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=202, - content_type='') - + url, + body=json.dumps(response), + status=202, + content_type='') + def call_service(self, body): service = AssistantV1( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.delete_user_data(**body) return output @@ -3902,7 +3498,6 @@ def check_empty_required_params(obj, response): error = True assert error - def check_missing_required_params(obj): """Test function to assert that the operation will throw an error when missing required data @@ -3919,7 +3514,6 @@ def check_missing_required_params(obj): error = True assert error - def check_empty_response(obj): """Test function to assert that the operation will return an empty response when given an empty request @@ -3931,7 +3525,6 @@ def check_empty_response(obj): url = obj.make_url(body) send_request(obj, {}, {}, url=url) - def send_request(obj, body, response, url=None): """Test function to create a request, send it, and assert its accuracy to the mock response @@ -3948,7 +3541,6 @@ def send_request(obj, body, response, url=None): assert responses.calls[0].request.url.startswith(url) assert output.get_result() == response - #################### ## Mock Responses ## #################### diff --git a/test/unit/test_assistant_v2.py b/test/unit/test_assistant_v2.py index 46887549b..30824422a 100644 --- a/test/unit/test_assistant_v2.py +++ b/test/unit/test_assistant_v2.py @@ -28,7 +28,6 @@ ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for create_session #----------------------------------------------------------------------------- @@ -74,16 +73,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=201, - content_type='application/json') - + url, + body=json.dumps(response), + status=201, + content_type='application/json') + def call_service(self, body): service = AssistantV2( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.create_session(**body) return output @@ -138,23 +137,22 @@ def test_delete_session_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v2/assistants/{0}/sessions/{1}'.format( - body['assistant_id'], body['session_id']) + endpoint = '/v2/assistants/{0}/sessions/{1}'.format(body['assistant_id'], body['session_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): service = AssistantV2( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.delete_session(**body) return output @@ -182,7 +180,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for message #----------------------------------------------------------------------------- @@ -222,23 +219,22 @@ def test_message_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v2/assistants/{0}/sessions/{1}/message'.format( - body['assistant_id'], body['session_id']) + endpoint = '/v2/assistants/{0}/sessions/{1}/message'.format(body['assistant_id'], body['session_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = AssistantV2( authenticator=NoAuthAuthenticator(), - version='2019-02-28', - ) + version='2020-04-01', + ) service.set_service_url(base_url) output = service.message(**body) return output @@ -247,18 +243,7 @@ def construct_full_body(self): body = dict() body['assistant_id'] = "string1" body['session_id'] = "string1" - body.update({ - "input": - MessageInput._from_dict( - json.loads( - """{"message_type": "fake_message_type", "text": "fake_text", "options": {"debug": false, "restart": false, "alternate_intents": false, "return_context": true}, "intents": [], "entities": [], "suggestion_id": "fake_suggestion_id"}""" - )), - "context": - MessageContext._from_dict( - json.loads( - """{"global": {"system": {"timezone": "fake_timezone", "user_id": "fake_user_id", "turn_count": 10, "locale": "fake_locale", "reference_time": "fake_reference_time"}}, "skills": {}}""" - )), - }) + body.update({"input": MessageInput._from_dict(json.loads("""{"message_type": "fake_message_type", "text": "fake_text", "options": {"debug": false, "restart": false, "alternate_intents": false, "return_context": true, "export": true}, "intents": [], "entities": [], "suggestion_id": "fake_suggestion_id"}""")), "context": MessageContext._from_dict(json.loads("""{"global": {"system": {"timezone": "fake_timezone", "user_id": "fake_user_id", "turn_count": 10, "locale": "fake_locale", "reference_time": "fake_reference_time"}}, "skills": {}}""")), }) return body def construct_required_body(self): @@ -290,7 +275,6 @@ def check_empty_required_params(obj, response): error = True assert error - def check_missing_required_params(obj): """Test function to assert that the operation will throw an error when missing required data @@ -307,7 +291,6 @@ def check_missing_required_params(obj): error = True assert error - def check_empty_response(obj): """Test function to assert that the operation will return an empty response when given an empty request @@ -319,7 +302,6 @@ def check_empty_response(obj): url = obj.make_url(body) send_request(obj, {}, {}, url=url) - def send_request(obj, body, response, url=None): """Test function to create a request, send it, and assert its accuracy to the mock response @@ -336,7 +318,6 @@ def send_request(obj, body, response, url=None): assert responses.calls[0].request.url.startswith(url) assert output.get_result() == response - #################### ## Mock Responses ## #################### diff --git a/test/unit/test_compare_comply_v1.py b/test/unit/test_compare_comply_v1.py index 7b54f1773..753607be4 100644 --- a/test/unit/test_compare_comply_v1.py +++ b/test/unit/test_compare_comply_v1.py @@ -30,7 +30,6 @@ ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for convert_to_html #----------------------------------------------------------------------------- @@ -76,16 +75,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = CompareComplyV1( authenticator=NoAuthAuthenticator(), version='2018-10-15', - ) + ) service.set_service_url(base_url) output = service.convert_to_html(**body) return output @@ -113,7 +112,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for classify_elements #----------------------------------------------------------------------------- @@ -159,16 +157,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = CompareComplyV1( authenticator=NoAuthAuthenticator(), version='2018-10-15', - ) + ) service.set_service_url(base_url) output = service.classify_elements(**body) return output @@ -196,7 +194,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for extract_tables #----------------------------------------------------------------------------- @@ -242,16 +239,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = CompareComplyV1( authenticator=NoAuthAuthenticator(), version='2018-10-15', - ) + ) service.set_service_url(base_url) output = service.extract_tables(**body) return output @@ -279,7 +276,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for compare_documents #----------------------------------------------------------------------------- @@ -325,16 +321,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = CompareComplyV1( authenticator=NoAuthAuthenticator(), version='2018-10-15', - ) + ) service.set_service_url(base_url) output = service.compare_documents(**body) return output @@ -367,7 +363,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for add_feedback #----------------------------------------------------------------------------- @@ -413,48 +408,28 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = CompareComplyV1( authenticator=NoAuthAuthenticator(), version='2018-10-15', - ) + ) service.set_service_url(base_url) output = service.add_feedback(**body) return output def construct_full_body(self): body = dict() - body.update({ - "feedback_data": - FeedbackDataInput._from_dict( - json.loads( - """{"feedback_type": "fake_feedback_type", "document": {"title": "fake_title", "hash": "fake_hash"}, "model_id": "fake_model_id", "model_version": "fake_model_version", "location": {"begin": 5, "end": 3}, "text": "fake_text", "original_labels": {"types": [], "categories": []}, "updated_labels": {"types": [], "categories": []}}""" - )), - "user_id": - "string1", - "comment": - "string1", - }) + body.update({"feedback_data": FeedbackDataInput._from_dict(json.loads("""{"feedback_type": "fake_feedback_type", "document": {"title": "fake_title", "hash": "fake_hash"}, "model_id": "fake_model_id", "model_version": "fake_model_version", "location": {"begin": 5, "end": 3}, "text": "fake_text", "original_labels": {"types": [], "categories": []}, "updated_labels": {"types": [], "categories": []}}""")), "user_id": "string1", "comment": "string1", }) return body def construct_required_body(self): body = dict() - body.update({ - "feedback_data": - FeedbackDataInput._from_dict( - json.loads( - """{"feedback_type": "fake_feedback_type", "document": {"title": "fake_title", "hash": "fake_hash"}, "model_id": "fake_model_id", "model_version": "fake_model_version", "location": {"begin": 5, "end": 3}, "text": "fake_text", "original_labels": {"types": [], "categories": []}, "updated_labels": {"types": [], "categories": []}}""" - )), - "user_id": - "string1", - "comment": - "string1", - }) + body.update({"feedback_data": FeedbackDataInput._from_dict(json.loads("""{"feedback_type": "fake_feedback_type", "document": {"title": "fake_title", "hash": "fake_hash"}, "model_id": "fake_model_id", "model_version": "fake_model_version", "location": {"begin": 5, "end": 3}, "text": "fake_text", "original_labels": {"types": [], "categories": []}, "updated_labels": {"types": [], "categories": []}}""")), "user_id": "string1", "comment": "string1", }) return body @@ -502,16 +477,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = CompareComplyV1( authenticator=NoAuthAuthenticator(), version='2018-10-15', - ) + ) service.set_service_url(base_url) output = service.list_feedback(**body) return output @@ -586,16 +561,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = CompareComplyV1( authenticator=NoAuthAuthenticator(), version='2018-10-15', - ) + ) service.set_service_url(base_url) output = service.get_feedback(**body) return output @@ -657,16 +632,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = CompareComplyV1( authenticator=NoAuthAuthenticator(), version='2018-10-15', - ) + ) service.set_service_url(base_url) output = service.delete_feedback(**body) return output @@ -693,7 +668,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for create_batch #----------------------------------------------------------------------------- @@ -739,16 +713,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = CompareComplyV1( authenticator=NoAuthAuthenticator(), version='2018-10-15', - ) + ) service.set_service_url(base_url) output = service.create_batch(**body) return output @@ -821,16 +795,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = CompareComplyV1( authenticator=NoAuthAuthenticator(), version='2018-10-15', - ) + ) service.set_service_url(base_url) output = service.list_batches(**body) return output @@ -889,16 +863,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = CompareComplyV1( authenticator=NoAuthAuthenticator(), version='2018-10-15', - ) + ) service.set_service_url(base_url) output = service.get_batch(**body) return output @@ -959,16 +933,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.PUT, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = CompareComplyV1( authenticator=NoAuthAuthenticator(), version='2018-10-15', - ) + ) service.set_service_url(base_url) output = service.update_batch(**body) return output @@ -1009,7 +983,6 @@ def check_empty_required_params(obj, response): error = True assert error - def check_missing_required_params(obj): """Test function to assert that the operation will throw an error when missing required data @@ -1026,7 +999,6 @@ def check_missing_required_params(obj): error = True assert error - def check_empty_response(obj): """Test function to assert that the operation will return an empty response when given an empty request @@ -1038,7 +1010,6 @@ def check_empty_response(obj): url = obj.make_url(body) send_request(obj, {}, {}, url=url) - def send_request(obj, body, response, url=None): """Test function to create a request, send it, and assert its accuracy to the mock response @@ -1055,7 +1026,6 @@ def send_request(obj, body, response, url=None): assert responses.calls[0].request.url.startswith(url) assert output.get_result() == response - #################### ## Mock Responses ## #################### diff --git a/test/unit/test_discovery_v1.py b/test/unit/test_discovery_v1.py index 07c5b3914..d18699074 100644 --- a/test/unit/test_discovery_v1.py +++ b/test/unit/test_discovery_v1.py @@ -30,7 +30,6 @@ ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for create_environment #----------------------------------------------------------------------------- @@ -76,36 +75,28 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=201, - content_type='application/json') - + url, + body=json.dumps(response), + status=201, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.create_environment(**body) return output def construct_full_body(self): body = dict() - body.update({ - "name": "string1", - "description": "string1", - "size": "string1", - }) + body.update({"name": "string1", "description": "string1", "size": "string1", }) return body def construct_required_body(self): body = dict() - body.update({ - "name": "string1", - "description": "string1", - "size": "string1", - }) + body.update({"name": "string1", "description": "string1", "size": "string1", }) return body @@ -153,16 +144,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.list_environments(**body) return output @@ -222,16 +213,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.get_environment(**body) return output @@ -292,16 +283,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.PUT, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.update_environment(**body) return output @@ -309,21 +300,13 @@ def call_service(self, body): def construct_full_body(self): body = dict() body['environment_id'] = "string1" - body.update({ - "name": "string1", - "description": "string1", - "size": "string1", - }) + body.update({"name": "string1", "description": "string1", "size": "string1", }) return body def construct_required_body(self): body = dict() body['environment_id'] = "string1" - body.update({ - "name": "string1", - "description": "string1", - "size": "string1", - }) + body.update({"name": "string1", "description": "string1", "size": "string1", }) return body @@ -358,8 +341,7 @@ def test_delete_environment_required_response(self): #-------------------------------------------------------- @responses.activate def test_delete_environment_empty(self): - check_empty_required_params( - self, fake_response_DeleteEnvironmentResponse_json) + check_empty_required_params(self, fake_response_DeleteEnvironmentResponse_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -373,16 +355,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.delete_environment(**body) return output @@ -429,8 +411,7 @@ def test_list_fields_required_response(self): #-------------------------------------------------------- @responses.activate def test_list_fields_empty(self): - check_empty_required_params( - self, fake_response_ListCollectionFieldsResponse_json) + check_empty_required_params(self, fake_response_ListCollectionFieldsResponse_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -444,16 +425,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.list_fields(**body) return output @@ -481,7 +462,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for create_configuration #----------------------------------------------------------------------------- @@ -521,23 +501,22 @@ def test_create_configuration_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/configurations'.format( - body['environment_id']) + endpoint = '/v1/environments/{0}/configurations'.format(body['environment_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=201, - content_type='application/json') - + url, + body=json.dumps(response), + status=201, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.create_configuration(**body) return output @@ -545,47 +524,13 @@ def call_service(self, body): def construct_full_body(self): body = dict() body['environment_id'] = "string1" - body.update({ - "name": - "string1", - "description": - "string1", - "conversions": - Conversions._from_dict( - json.loads( - """{"pdf": {"heading": {"fonts": []}}, "word": {"heading": {"fonts": [], "styles": []}}, "html": {"exclude_tags_completely": [], "exclude_tags_keep_content": [], "keep_content": {"xpaths": []}, "exclude_content": {"xpaths": []}, "keep_tag_attributes": [], "exclude_tag_attributes": []}, "segment": {"enabled": false, "selector_tags": [], "annotated_fields": []}, "json_normalizations": [], "image_text_recognition": true}""" - )), - "enrichments": [], - "normalizations": [], - "source": - Source._from_dict( - json.loads( - """{"type": "fake_type", "credential_id": "fake_credential_id", "schedule": {"enabled": false, "time_zone": "fake_time_zone", "frequency": "fake_frequency"}, "options": {"folders": [], "objects": [], "site_collections": [], "urls": [], "buckets": [], "crawl_all_buckets": false}}""" - )), - }) + body.update({"name": "string1", "description": "string1", "conversions": Conversions._from_dict(json.loads("""{"pdf": {"heading": {"fonts": []}}, "word": {"heading": {"fonts": [], "styles": []}}, "html": {"exclude_tags_completely": [], "exclude_tags_keep_content": [], "keep_content": {"xpaths": []}, "exclude_content": {"xpaths": []}, "keep_tag_attributes": [], "exclude_tag_attributes": []}, "segment": {"enabled": false, "selector_tags": [], "annotated_fields": []}, "json_normalizations": [], "image_text_recognition": true}""")), "enrichments": [], "normalizations": [], "source": Source._from_dict(json.loads("""{"type": "fake_type", "credential_id": "fake_credential_id", "schedule": {"enabled": false, "time_zone": "fake_time_zone", "frequency": "fake_frequency"}, "options": {"folders": [], "objects": [], "site_collections": [], "urls": [], "buckets": [], "crawl_all_buckets": false}}""")), }) return body def construct_required_body(self): body = dict() body['environment_id'] = "string1" - body.update({ - "name": - "string1", - "description": - "string1", - "conversions": - Conversions._from_dict( - json.loads( - """{"pdf": {"heading": {"fonts": []}}, "word": {"heading": {"fonts": [], "styles": []}}, "html": {"exclude_tags_completely": [], "exclude_tags_keep_content": [], "keep_content": {"xpaths": []}, "exclude_content": {"xpaths": []}, "keep_tag_attributes": [], "exclude_tag_attributes": []}, "segment": {"enabled": false, "selector_tags": [], "annotated_fields": []}, "json_normalizations": [], "image_text_recognition": true}""" - )), - "enrichments": [], - "normalizations": [], - "source": - Source._from_dict( - json.loads( - """{"type": "fake_type", "credential_id": "fake_credential_id", "schedule": {"enabled": false, "time_zone": "fake_time_zone", "frequency": "fake_frequency"}, "options": {"folders": [], "objects": [], "site_collections": [], "urls": [], "buckets": [], "crawl_all_buckets": false}}""" - )), - }) + body.update({"name": "string1", "description": "string1", "conversions": Conversions._from_dict(json.loads("""{"pdf": {"heading": {"fonts": []}}, "word": {"heading": {"fonts": [], "styles": []}}, "html": {"exclude_tags_completely": [], "exclude_tags_keep_content": [], "keep_content": {"xpaths": []}, "exclude_content": {"xpaths": []}, "keep_tag_attributes": [], "exclude_tag_attributes": []}, "segment": {"enabled": false, "selector_tags": [], "annotated_fields": []}, "json_normalizations": [], "image_text_recognition": true}""")), "enrichments": [], "normalizations": [], "source": Source._from_dict(json.loads("""{"type": "fake_type", "credential_id": "fake_credential_id", "schedule": {"enabled": false, "time_zone": "fake_time_zone", "frequency": "fake_frequency"}, "options": {"folders": [], "objects": [], "site_collections": [], "urls": [], "buckets": [], "crawl_all_buckets": false}}""")), }) return body @@ -620,8 +565,7 @@ def test_list_configurations_required_response(self): #-------------------------------------------------------- @responses.activate def test_list_configurations_empty(self): - check_empty_required_params( - self, fake_response_ListConfigurationsResponse_json) + check_empty_required_params(self, fake_response_ListConfigurationsResponse_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -629,23 +573,22 @@ def test_list_configurations_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/configurations'.format( - body['environment_id']) + endpoint = '/v1/environments/{0}/configurations'.format(body['environment_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.list_configurations(**body) return output @@ -701,23 +644,22 @@ def test_get_configuration_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/configurations/{1}'.format( - body['environment_id'], body['configuration_id']) + endpoint = '/v1/environments/{0}/configurations/{1}'.format(body['environment_id'], body['configuration_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.get_configuration(**body) return output @@ -774,23 +716,22 @@ def test_update_configuration_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/configurations/{1}'.format( - body['environment_id'], body['configuration_id']) + endpoint = '/v1/environments/{0}/configurations/{1}'.format(body['environment_id'], body['configuration_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.PUT, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.update_configuration(**body) return output @@ -799,48 +740,14 @@ def construct_full_body(self): body = dict() body['environment_id'] = "string1" body['configuration_id'] = "string1" - body.update({ - "name": - "string1", - "description": - "string1", - "conversions": - Conversions._from_dict( - json.loads( - """{"pdf": {"heading": {"fonts": []}}, "word": {"heading": {"fonts": [], "styles": []}}, "html": {"exclude_tags_completely": [], "exclude_tags_keep_content": [], "keep_content": {"xpaths": []}, "exclude_content": {"xpaths": []}, "keep_tag_attributes": [], "exclude_tag_attributes": []}, "segment": {"enabled": false, "selector_tags": [], "annotated_fields": []}, "json_normalizations": [], "image_text_recognition": true}""" - )), - "enrichments": [], - "normalizations": [], - "source": - Source._from_dict( - json.loads( - """{"type": "fake_type", "credential_id": "fake_credential_id", "schedule": {"enabled": false, "time_zone": "fake_time_zone", "frequency": "fake_frequency"}, "options": {"folders": [], "objects": [], "site_collections": [], "urls": [], "buckets": [], "crawl_all_buckets": false}}""" - )), - }) + body.update({"name": "string1", "description": "string1", "conversions": Conversions._from_dict(json.loads("""{"pdf": {"heading": {"fonts": []}}, "word": {"heading": {"fonts": [], "styles": []}}, "html": {"exclude_tags_completely": [], "exclude_tags_keep_content": [], "keep_content": {"xpaths": []}, "exclude_content": {"xpaths": []}, "keep_tag_attributes": [], "exclude_tag_attributes": []}, "segment": {"enabled": false, "selector_tags": [], "annotated_fields": []}, "json_normalizations": [], "image_text_recognition": true}""")), "enrichments": [], "normalizations": [], "source": Source._from_dict(json.loads("""{"type": "fake_type", "credential_id": "fake_credential_id", "schedule": {"enabled": false, "time_zone": "fake_time_zone", "frequency": "fake_frequency"}, "options": {"folders": [], "objects": [], "site_collections": [], "urls": [], "buckets": [], "crawl_all_buckets": false}}""")), }) return body def construct_required_body(self): body = dict() body['environment_id'] = "string1" body['configuration_id'] = "string1" - body.update({ - "name": - "string1", - "description": - "string1", - "conversions": - Conversions._from_dict( - json.loads( - """{"pdf": {"heading": {"fonts": []}}, "word": {"heading": {"fonts": [], "styles": []}}, "html": {"exclude_tags_completely": [], "exclude_tags_keep_content": [], "keep_content": {"xpaths": []}, "exclude_content": {"xpaths": []}, "keep_tag_attributes": [], "exclude_tag_attributes": []}, "segment": {"enabled": false, "selector_tags": [], "annotated_fields": []}, "json_normalizations": [], "image_text_recognition": true}""" - )), - "enrichments": [], - "normalizations": [], - "source": - Source._from_dict( - json.loads( - """{"type": "fake_type", "credential_id": "fake_credential_id", "schedule": {"enabled": false, "time_zone": "fake_time_zone", "frequency": "fake_frequency"}, "options": {"folders": [], "objects": [], "site_collections": [], "urls": [], "buckets": [], "crawl_all_buckets": false}}""" - )), - }) + body.update({"name": "string1", "description": "string1", "conversions": Conversions._from_dict(json.loads("""{"pdf": {"heading": {"fonts": []}}, "word": {"heading": {"fonts": [], "styles": []}}, "html": {"exclude_tags_completely": [], "exclude_tags_keep_content": [], "keep_content": {"xpaths": []}, "exclude_content": {"xpaths": []}, "keep_tag_attributes": [], "exclude_tag_attributes": []}, "segment": {"enabled": false, "selector_tags": [], "annotated_fields": []}, "json_normalizations": [], "image_text_recognition": true}""")), "enrichments": [], "normalizations": [], "source": Source._from_dict(json.loads("""{"type": "fake_type", "credential_id": "fake_credential_id", "schedule": {"enabled": false, "time_zone": "fake_time_zone", "frequency": "fake_frequency"}, "options": {"folders": [], "objects": [], "site_collections": [], "urls": [], "buckets": [], "crawl_all_buckets": false}}""")), }) return body @@ -875,8 +782,7 @@ def test_delete_configuration_required_response(self): #-------------------------------------------------------- @responses.activate def test_delete_configuration_empty(self): - check_empty_required_params( - self, fake_response_DeleteConfigurationResponse_json) + check_empty_required_params(self, fake_response_DeleteConfigurationResponse_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -884,23 +790,22 @@ def test_delete_configuration_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/configurations/{1}'.format( - body['environment_id'], body['configuration_id']) + endpoint = '/v1/environments/{0}/configurations/{1}'.format(body['environment_id'], body['configuration_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.delete_configuration(**body) return output @@ -928,7 +833,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for create_collection #----------------------------------------------------------------------------- @@ -968,23 +872,22 @@ def test_create_collection_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections'.format( - body['environment_id']) + endpoint = '/v1/environments/{0}/collections'.format(body['environment_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=201, - content_type='application/json') - + url, + body=json.dumps(response), + status=201, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.create_collection(**body) return output @@ -992,23 +895,13 @@ def call_service(self, body): def construct_full_body(self): body = dict() body['environment_id'] = "string1" - body.update({ - "name": "string1", - "description": "string1", - "configuration_id": "string1", - "language": "string1", - }) + body.update({"name": "string1", "description": "string1", "configuration_id": "string1", "language": "string1", }) return body def construct_required_body(self): body = dict() body['environment_id'] = "string1" - body.update({ - "name": "string1", - "description": "string1", - "configuration_id": "string1", - "language": "string1", - }) + body.update({"name": "string1", "description": "string1", "configuration_id": "string1", "language": "string1", }) return body @@ -1043,8 +936,7 @@ def test_list_collections_required_response(self): #-------------------------------------------------------- @responses.activate def test_list_collections_empty(self): - check_empty_required_params(self, - fake_response_ListCollectionsResponse_json) + check_empty_required_params(self, fake_response_ListCollectionsResponse_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -1052,23 +944,22 @@ def test_list_collections_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections'.format( - body['environment_id']) + endpoint = '/v1/environments/{0}/collections'.format(body['environment_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.list_collections(**body) return output @@ -1124,23 +1015,22 @@ def test_get_collection_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}'.format( - body['environment_id'], body['collection_id']) + endpoint = '/v1/environments/{0}/collections/{1}'.format(body['environment_id'], body['collection_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.get_collection(**body) return output @@ -1197,23 +1087,22 @@ def test_update_collection_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}'.format( - body['environment_id'], body['collection_id']) + endpoint = '/v1/environments/{0}/collections/{1}'.format(body['environment_id'], body['collection_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.PUT, - url, - body=json.dumps(response), - status=201, - content_type='application/json') - + url, + body=json.dumps(response), + status=201, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.update_collection(**body) return output @@ -1222,22 +1111,14 @@ def construct_full_body(self): body = dict() body['environment_id'] = "string1" body['collection_id'] = "string1" - body.update({ - "name": "string1", - "description": "string1", - "configuration_id": "string1", - }) + body.update({"name": "string1", "description": "string1", "configuration_id": "string1", }) return body def construct_required_body(self): body = dict() body['environment_id'] = "string1" body['collection_id'] = "string1" - body.update({ - "name": "string1", - "description": "string1", - "configuration_id": "string1", - }) + body.update({"name": "string1", "description": "string1", "configuration_id": "string1", }) return body @@ -1272,8 +1153,7 @@ def test_delete_collection_required_response(self): #-------------------------------------------------------- @responses.activate def test_delete_collection_empty(self): - check_empty_required_params( - self, fake_response_DeleteCollectionResponse_json) + check_empty_required_params(self, fake_response_DeleteCollectionResponse_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -1281,23 +1161,22 @@ def test_delete_collection_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}'.format( - body['environment_id'], body['collection_id']) + endpoint = '/v1/environments/{0}/collections/{1}'.format(body['environment_id'], body['collection_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.delete_collection(**body) return output @@ -1346,8 +1225,7 @@ def test_list_collection_fields_required_response(self): #-------------------------------------------------------- @responses.activate def test_list_collection_fields_empty(self): - check_empty_required_params( - self, fake_response_ListCollectionFieldsResponse_json) + check_empty_required_params(self, fake_response_ListCollectionFieldsResponse_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -1355,23 +1233,22 @@ def test_list_collection_fields_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/fields'.format( - body['environment_id'], body['collection_id']) + endpoint = '/v1/environments/{0}/collections/{1}/fields'.format(body['environment_id'], body['collection_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.list_collection_fields(**body) return output @@ -1399,7 +1276,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_expansions #----------------------------------------------------------------------------- @@ -1439,23 +1315,22 @@ def test_list_expansions_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/expansions'.format( - body['environment_id'], body['collection_id']) + endpoint = '/v1/environments/{0}/collections/{1}/expansions'.format(body['environment_id'], body['collection_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.list_expansions(**body) return output @@ -1512,23 +1387,22 @@ def test_create_expansions_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/expansions'.format( - body['environment_id'], body['collection_id']) + endpoint = '/v1/environments/{0}/collections/{1}/expansions'.format(body['environment_id'], body['collection_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.create_expansions(**body) return output @@ -1537,18 +1411,14 @@ def construct_full_body(self): body = dict() body['environment_id'] = "string1" body['collection_id'] = "string1" - body.update({ - "expansions": [], - }) + body.update({"expansions": [], }) return body def construct_required_body(self): body = dict() body['environment_id'] = "string1" body['collection_id'] = "string1" - body.update({ - "expansions": [], - }) + body.update({"expansions": [], }) return body @@ -1591,23 +1461,22 @@ def test_delete_expansions_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/expansions'.format( - body['environment_id'], body['collection_id']) + endpoint = '/v1/environments/{0}/collections/{1}/expansions'.format(body['environment_id'], body['collection_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=204, - content_type='') - + url, + body=json.dumps(response), + status=204, + content_type='') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.delete_expansions(**body) return output @@ -1656,8 +1525,7 @@ def test_get_tokenization_dictionary_status_required_response(self): #-------------------------------------------------------- @responses.activate def test_get_tokenization_dictionary_status_empty(self): - check_empty_required_params(self, - fake_response_TokenDictStatusResponse_json) + check_empty_required_params(self, fake_response_TokenDictStatusResponse_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -1665,23 +1533,22 @@ def test_get_tokenization_dictionary_status_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/word_lists/tokenization_dictionary'.format( - body['environment_id'], body['collection_id']) + endpoint = '/v1/environments/{0}/collections/{1}/word_lists/tokenization_dictionary'.format(body['environment_id'], body['collection_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.get_tokenization_dictionary_status(**body) return output @@ -1730,8 +1597,7 @@ def test_create_tokenization_dictionary_required_response(self): #-------------------------------------------------------- @responses.activate def test_create_tokenization_dictionary_empty(self): - check_empty_required_params(self, - fake_response_TokenDictStatusResponse_json) + check_empty_required_params(self, fake_response_TokenDictStatusResponse_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -1739,23 +1605,22 @@ def test_create_tokenization_dictionary_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/word_lists/tokenization_dictionary'.format( - body['environment_id'], body['collection_id']) + endpoint = '/v1/environments/{0}/collections/{1}/word_lists/tokenization_dictionary'.format(body['environment_id'], body['collection_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=202, - content_type='application/json') - + url, + body=json.dumps(response), + status=202, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.create_tokenization_dictionary(**body) return output @@ -1764,9 +1629,7 @@ def construct_full_body(self): body = dict() body['environment_id'] = "string1" body['collection_id'] = "string1" - body.update({ - "tokenization_rules": [], - }) + body.update({"tokenization_rules": [], }) return body def construct_required_body(self): @@ -1815,23 +1678,22 @@ def test_delete_tokenization_dictionary_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/word_lists/tokenization_dictionary'.format( - body['environment_id'], body['collection_id']) + endpoint = '/v1/environments/{0}/collections/{1}/word_lists/tokenization_dictionary'.format(body['environment_id'], body['collection_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.delete_tokenization_dictionary(**body) return output @@ -1880,8 +1742,7 @@ def test_get_stopword_list_status_required_response(self): #-------------------------------------------------------- @responses.activate def test_get_stopword_list_status_empty(self): - check_empty_required_params(self, - fake_response_TokenDictStatusResponse_json) + check_empty_required_params(self, fake_response_TokenDictStatusResponse_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -1889,23 +1750,22 @@ def test_get_stopword_list_status_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/word_lists/stopwords'.format( - body['environment_id'], body['collection_id']) + endpoint = '/v1/environments/{0}/collections/{1}/word_lists/stopwords'.format(body['environment_id'], body['collection_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.get_stopword_list_status(**body) return output @@ -1954,8 +1814,7 @@ def test_create_stopword_list_required_response(self): #-------------------------------------------------------- @responses.activate def test_create_stopword_list_empty(self): - check_empty_required_params(self, - fake_response_TokenDictStatusResponse_json) + check_empty_required_params(self, fake_response_TokenDictStatusResponse_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -1963,23 +1822,22 @@ def test_create_stopword_list_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/word_lists/stopwords'.format( - body['environment_id'], body['collection_id']) + endpoint = '/v1/environments/{0}/collections/{1}/word_lists/stopwords'.format(body['environment_id'], body['collection_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.create_stopword_list(**body) return output @@ -2039,23 +1897,22 @@ def test_delete_stopword_list_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/word_lists/stopwords'.format( - body['environment_id'], body['collection_id']) + endpoint = '/v1/environments/{0}/collections/{1}/word_lists/stopwords'.format(body['environment_id'], body['collection_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.delete_stopword_list(**body) return output @@ -2083,7 +1940,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for add_document #----------------------------------------------------------------------------- @@ -2123,23 +1979,22 @@ def test_add_document_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/documents'.format( - body['environment_id'], body['collection_id']) + endpoint = '/v1/environments/{0}/collections/{1}/documents'.format(body['environment_id'], body['collection_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=202, - content_type='application/json') - + url, + body=json.dumps(response), + status=202, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.add_document(**body) return output @@ -2200,23 +2055,22 @@ def test_get_document_status_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/documents/{2}'.format( - body['environment_id'], body['collection_id'], body['document_id']) + endpoint = '/v1/environments/{0}/collections/{1}/documents/{2}'.format(body['environment_id'], body['collection_id'], body['document_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.get_document_status(**body) return output @@ -2275,23 +2129,22 @@ def test_update_document_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/documents/{2}'.format( - body['environment_id'], body['collection_id'], body['document_id']) + endpoint = '/v1/environments/{0}/collections/{1}/documents/{2}'.format(body['environment_id'], body['collection_id'], body['document_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=202, - content_type='application/json') - + url, + body=json.dumps(response), + status=202, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.update_document(**body) return output @@ -2346,8 +2199,7 @@ def test_delete_document_required_response(self): #-------------------------------------------------------- @responses.activate def test_delete_document_empty(self): - check_empty_required_params(self, - fake_response_DeleteDocumentResponse_json) + check_empty_required_params(self, fake_response_DeleteDocumentResponse_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -2355,23 +2207,22 @@ def test_delete_document_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/documents/{2}'.format( - body['environment_id'], body['collection_id'], body['document_id']) + endpoint = '/v1/environments/{0}/collections/{1}/documents/{2}'.format(body['environment_id'], body['collection_id'], body['document_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.delete_document(**body) return output @@ -2401,7 +2252,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for query #----------------------------------------------------------------------------- @@ -2441,23 +2291,22 @@ def test_query_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/query'.format( - body['environment_id'], body['collection_id']) + endpoint = '/v1/environments/{0}/collections/{1}/query'.format(body['environment_id'], body['collection_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.query(**body) return output @@ -2466,28 +2315,7 @@ def construct_full_body(self): body = dict() body['environment_id'] = "string1" body['collection_id'] = "string1" - body.update({ - "filter": "string1", - "query": "string1", - "natural_language_query": "string1", - "passages": True, - "aggregation": "string1", - "count": 12345, - "return_": "string1", - "offset": 12345, - "sort": "string1", - "highlight": True, - "passages_fields": "string1", - "passages_count": 12345, - "passages_characters": 12345, - "deduplicate": True, - "deduplicate_field": "string1", - "similar": True, - "similar_document_ids": "string1", - "similar_fields": "string1", - "bias": "string1", - "spelling_suggestions": True, - }) + body.update({"filter": "string1", "query": "string1", "natural_language_query": "string1", "passages": True, "aggregation": "string1", "count": 12345, "return_": "string1", "offset": 12345, "sort": "string1", "highlight": True, "passages_fields": "string1", "passages_count": 12345, "passages_characters": 12345, "deduplicate": True, "deduplicate_field": "string1", "similar": True, "similar_document_ids": "string1", "similar_fields": "string1", "bias": "string1", "spelling_suggestions": True, }) body['x_watson_logging_opt_out'] = True return body @@ -2529,8 +2357,7 @@ def test_query_notices_required_response(self): #-------------------------------------------------------- @responses.activate def test_query_notices_empty(self): - check_empty_required_params(self, - fake_response_QueryNoticesResponse_json) + check_empty_required_params(self, fake_response_QueryNoticesResponse_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -2538,23 +2365,22 @@ def test_query_notices_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/notices'.format( - body['environment_id'], body['collection_id']) + endpoint = '/v1/environments/{0}/collections/{1}/notices'.format(body['environment_id'], body['collection_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.query_notices(**body) return output @@ -2634,16 +2460,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.federated_query(**body) return output @@ -2651,56 +2477,14 @@ def call_service(self, body): def construct_full_body(self): body = dict() body['environment_id'] = "string1" - body.update({ - "collection_ids": "string1", - "filter": "string1", - "query": "string1", - "natural_language_query": "string1", - "passages": True, - "aggregation": "string1", - "count": 12345, - "return_": "string1", - "offset": 12345, - "sort": "string1", - "highlight": True, - "passages_fields": "string1", - "passages_count": 12345, - "passages_characters": 12345, - "deduplicate": True, - "deduplicate_field": "string1", - "similar": True, - "similar_document_ids": "string1", - "similar_fields": "string1", - "bias": "string1", - }) + body.update({"collection_ids": "string1", "filter": "string1", "query": "string1", "natural_language_query": "string1", "passages": True, "aggregation": "string1", "count": 12345, "return_": "string1", "offset": 12345, "sort": "string1", "highlight": True, "passages_fields": "string1", "passages_count": 12345, "passages_characters": 12345, "deduplicate": True, "deduplicate_field": "string1", "similar": True, "similar_document_ids": "string1", "similar_fields": "string1", "bias": "string1", }) body['x_watson_logging_opt_out'] = True return body def construct_required_body(self): body = dict() body['environment_id'] = "string1" - body.update({ - "collection_ids": "string1", - "filter": "string1", - "query": "string1", - "natural_language_query": "string1", - "passages": True, - "aggregation": "string1", - "count": 12345, - "return_": "string1", - "offset": 12345, - "sort": "string1", - "highlight": True, - "passages_fields": "string1", - "passages_count": 12345, - "passages_characters": 12345, - "deduplicate": True, - "deduplicate_field": "string1", - "similar": True, - "similar_document_ids": "string1", - "similar_fields": "string1", - "bias": "string1", - }) + body.update({"collection_ids": "string1", "filter": "string1", "query": "string1", "natural_language_query": "string1", "passages": True, "aggregation": "string1", "count": 12345, "return_": "string1", "offset": 12345, "sort": "string1", "highlight": True, "passages_fields": "string1", "passages_count": 12345, "passages_characters": 12345, "deduplicate": True, "deduplicate_field": "string1", "similar": True, "similar_document_ids": "string1", "similar_fields": "string1", "bias": "string1", }) return body @@ -2735,8 +2519,7 @@ def test_federated_query_notices_required_response(self): #-------------------------------------------------------- @responses.activate def test_federated_query_notices_empty(self): - check_empty_required_params(self, - fake_response_QueryNoticesResponse_json) + check_empty_required_params(self, fake_response_QueryNoticesResponse_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -2750,16 +2533,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.federated_query_notices(**body) return output @@ -2829,23 +2612,22 @@ def test_get_autocompletion_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/autocompletion'.format( - body['environment_id'], body['collection_id']) + endpoint = '/v1/environments/{0}/collections/{1}/autocompletion'.format(body['environment_id'], body['collection_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.get_autocompletion(**body) return output @@ -2877,7 +2659,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_training_data #----------------------------------------------------------------------------- @@ -2917,23 +2698,22 @@ def test_list_training_data_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/training_data'.format( - body['environment_id'], body['collection_id']) + endpoint = '/v1/environments/{0}/collections/{1}/training_data'.format(body['environment_id'], body['collection_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.list_training_data(**body) return output @@ -2990,23 +2770,22 @@ def test_add_training_data_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/training_data'.format( - body['environment_id'], body['collection_id']) + endpoint = '/v1/environments/{0}/collections/{1}/training_data'.format(body['environment_id'], body['collection_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.add_training_data(**body) return output @@ -3015,22 +2794,14 @@ def construct_full_body(self): body = dict() body['environment_id'] = "string1" body['collection_id'] = "string1" - body.update({ - "natural_language_query": "string1", - "filter": "string1", - "examples": [], - }) + body.update({"natural_language_query": "string1", "filter": "string1", "examples": [], }) return body def construct_required_body(self): body = dict() body['environment_id'] = "string1" body['collection_id'] = "string1" - body.update({ - "natural_language_query": "string1", - "filter": "string1", - "examples": [], - }) + body.update({"natural_language_query": "string1", "filter": "string1", "examples": [], }) return body @@ -3073,23 +2844,22 @@ def test_delete_all_training_data_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/training_data'.format( - body['environment_id'], body['collection_id']) + endpoint = '/v1/environments/{0}/collections/{1}/training_data'.format(body['environment_id'], body['collection_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=204, - content_type='') - + url, + body=json.dumps(response), + status=204, + content_type='') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.delete_all_training_data(**body) return output @@ -3146,23 +2916,22 @@ def test_get_training_data_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/training_data/{2}'.format( - body['environment_id'], body['collection_id'], body['query_id']) + endpoint = '/v1/environments/{0}/collections/{1}/training_data/{2}'.format(body['environment_id'], body['collection_id'], body['query_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.get_training_data(**body) return output @@ -3221,23 +2990,22 @@ def test_delete_training_data_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/training_data/{2}'.format( - body['environment_id'], body['collection_id'], body['query_id']) + endpoint = '/v1/environments/{0}/collections/{1}/training_data/{2}'.format(body['environment_id'], body['collection_id'], body['query_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=204, - content_type='') - + url, + body=json.dumps(response), + status=204, + content_type='') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.delete_training_data(**body) return output @@ -3288,8 +3056,7 @@ def test_list_training_examples_required_response(self): #-------------------------------------------------------- @responses.activate def test_list_training_examples_empty(self): - check_empty_required_params(self, - fake_response_TrainingExampleList_json) + check_empty_required_params(self, fake_response_TrainingExampleList_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -3297,23 +3064,22 @@ def test_list_training_examples_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/training_data/{2}/examples'.format( - body['environment_id'], body['collection_id'], body['query_id']) + endpoint = '/v1/environments/{0}/collections/{1}/training_data/{2}/examples'.format(body['environment_id'], body['collection_id'], body['query_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.list_training_examples(**body) return output @@ -3372,23 +3138,22 @@ def test_create_training_example_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/training_data/{2}/examples'.format( - body['environment_id'], body['collection_id'], body['query_id']) + endpoint = '/v1/environments/{0}/collections/{1}/training_data/{2}/examples'.format(body['environment_id'], body['collection_id'], body['query_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=201, - content_type='application/json') - + url, + body=json.dumps(response), + status=201, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.create_training_example(**body) return output @@ -3398,11 +3163,7 @@ def construct_full_body(self): body['environment_id'] = "string1" body['collection_id'] = "string1" body['query_id'] = "string1" - body.update({ - "document_id": "string1", - "cross_reference": "string1", - "relevance": 12345, - }) + body.update({"document_id": "string1", "cross_reference": "string1", "relevance": 12345, }) return body def construct_required_body(self): @@ -3410,11 +3171,7 @@ def construct_required_body(self): body['environment_id'] = "string1" body['collection_id'] = "string1" body['query_id'] = "string1" - body.update({ - "document_id": "string1", - "cross_reference": "string1", - "relevance": 12345, - }) + body.update({"document_id": "string1", "cross_reference": "string1", "relevance": 12345, }) return body @@ -3457,24 +3214,22 @@ def test_delete_training_example_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/training_data/{2}/examples/{3}'.format( - body['environment_id'], body['collection_id'], body['query_id'], - body['example_id']) + endpoint = '/v1/environments/{0}/collections/{1}/training_data/{2}/examples/{3}'.format(body['environment_id'], body['collection_id'], body['query_id'], body['example_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=204, - content_type='') - + url, + body=json.dumps(response), + status=204, + content_type='') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.delete_training_example(**body) return output @@ -3535,24 +3290,22 @@ def test_update_training_example_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/training_data/{2}/examples/{3}'.format( - body['environment_id'], body['collection_id'], body['query_id'], - body['example_id']) + endpoint = '/v1/environments/{0}/collections/{1}/training_data/{2}/examples/{3}'.format(body['environment_id'], body['collection_id'], body['query_id'], body['example_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.PUT, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.update_training_example(**body) return output @@ -3563,10 +3316,7 @@ def construct_full_body(self): body['collection_id'] = "string1" body['query_id'] = "string1" body['example_id'] = "string1" - body.update({ - "cross_reference": "string1", - "relevance": 12345, - }) + body.update({"cross_reference": "string1", "relevance": 12345, }) return body def construct_required_body(self): @@ -3575,10 +3325,7 @@ def construct_required_body(self): body['collection_id'] = "string1" body['query_id'] = "string1" body['example_id'] = "string1" - body.update({ - "cross_reference": "string1", - "relevance": 12345, - }) + body.update({"cross_reference": "string1", "relevance": 12345, }) return body @@ -3621,24 +3368,22 @@ def test_get_training_example_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/collections/{1}/training_data/{2}/examples/{3}'.format( - body['environment_id'], body['collection_id'], body['query_id'], - body['example_id']) + endpoint = '/v1/environments/{0}/collections/{1}/training_data/{2}/examples/{3}'.format(body['environment_id'], body['collection_id'], body['query_id'], body['example_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.get_training_example(**body) return output @@ -3670,7 +3415,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for delete_user_data #----------------------------------------------------------------------------- @@ -3716,16 +3460,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.delete_user_data(**body) return output @@ -3751,7 +3495,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for create_event #----------------------------------------------------------------------------- @@ -3783,8 +3526,7 @@ def test_create_event_required_response(self): #-------------------------------------------------------- @responses.activate def test_create_event_empty(self): - check_empty_required_params(self, - fake_response_CreateEventResponse_json) + check_empty_required_params(self, fake_response_CreateEventResponse_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -3798,44 +3540,28 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=201, - content_type='application/json') - + url, + body=json.dumps(response), + status=201, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.create_event(**body) return output def construct_full_body(self): body = dict() - body.update({ - "type": - "string1", - "data": - EventData._from_dict( - json.loads( - """{"environment_id": "fake_environment_id", "session_token": "fake_session_token", "client_timestamp": "2017-05-16T13:56:54.957Z", "display_rank": 12, "collection_id": "fake_collection_id", "document_id": "fake_document_id", "query_id": "fake_query_id"}""" - )), - }) + body.update({"type": "string1", "data": EventData._from_dict(json.loads("""{"environment_id": "fake_environment_id", "session_token": "fake_session_token", "client_timestamp": "2017-05-16T13:56:54.957Z", "display_rank": 12, "collection_id": "fake_collection_id", "document_id": "fake_document_id", "query_id": "fake_query_id"}""")), }) return body def construct_required_body(self): body = dict() - body.update({ - "type": - "string1", - "data": - EventData._from_dict( - json.loads( - """{"environment_id": "fake_environment_id", "session_token": "fake_session_token", "client_timestamp": "2017-05-16T13:56:54.957Z", "display_rank": 12, "collection_id": "fake_collection_id", "document_id": "fake_document_id", "query_id": "fake_query_id"}""" - )), - }) + body.update({"type": "string1", "data": EventData._from_dict(json.loads("""{"environment_id": "fake_environment_id", "session_token": "fake_session_token", "client_timestamp": "2017-05-16T13:56:54.957Z", "display_rank": 12, "collection_id": "fake_collection_id", "document_id": "fake_document_id", "query_id": "fake_query_id"}""")), }) return body @@ -3883,16 +3609,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.query_log(**body) return output @@ -3955,16 +3681,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.get_metrics_query(**body) return output @@ -4025,16 +3751,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.get_metrics_query_event(**body) return output @@ -4095,16 +3821,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.get_metrics_query_no_results(**body) return output @@ -4165,16 +3891,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.get_metrics_event_rate(**body) return output @@ -4235,16 +3961,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.get_metrics_query_token_event(**body) return output @@ -4269,7 +3995,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_credentials #----------------------------------------------------------------------------- @@ -4309,23 +4034,22 @@ def test_list_credentials_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/credentials'.format( - body['environment_id']) + endpoint = '/v1/environments/{0}/credentials'.format(body['environment_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.list_credentials(**body) return output @@ -4380,23 +4104,22 @@ def test_create_credentials_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/credentials'.format( - body['environment_id']) + endpoint = '/v1/environments/{0}/credentials'.format(body['environment_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.create_credentials(**body) return output @@ -4404,33 +4127,13 @@ def call_service(self, body): def construct_full_body(self): body = dict() body['environment_id'] = "string1" - body.update({ - "source_type": - "string1", - "credential_details": - CredentialDetails._from_dict( - json.loads( - """{"credential_type": "fake_credential_type", "client_id": "fake_client_id", "enterprise_id": "fake_enterprise_id", "url": "fake_url", "username": "fake_username", "organization_url": "fake_organization_url", "site_collection.path": "fake_site_collection_path", "client_secret": "fake_client_secret", "public_key_id": "fake_public_key_id", "private_key": "fake_private_key", "passphrase": "fake_passphrase", "password": "fake_password", "gateway_id": "fake_gateway_id", "source_version": "fake_source_version", "web_application_url": "fake_web_application_url", "domain": "fake_domain", "endpoint": "fake_endpoint", "access_key_id": "fake_access_key_id", "secret_access_key": "fake_secret_access_key"}""" - )), - "status": - "string1", - }) + body.update({"source_type": "string1", "credential_details": CredentialDetails._from_dict(json.loads("""{"credential_type": "fake_credential_type", "client_id": "fake_client_id", "enterprise_id": "fake_enterprise_id", "url": "fake_url", "username": "fake_username", "organization_url": "fake_organization_url", "site_collection.path": "fake_site_collection_path", "client_secret": "fake_client_secret", "public_key_id": "fake_public_key_id", "private_key": "fake_private_key", "passphrase": "fake_passphrase", "password": "fake_password", "gateway_id": "fake_gateway_id", "source_version": "fake_source_version", "web_application_url": "fake_web_application_url", "domain": "fake_domain", "endpoint": "fake_endpoint", "access_key_id": "fake_access_key_id", "secret_access_key": "fake_secret_access_key"}""")), "status": "string1", }) return body def construct_required_body(self): body = dict() body['environment_id'] = "string1" - body.update({ - "source_type": - "string1", - "credential_details": - CredentialDetails._from_dict( - json.loads( - """{"credential_type": "fake_credential_type", "client_id": "fake_client_id", "enterprise_id": "fake_enterprise_id", "url": "fake_url", "username": "fake_username", "organization_url": "fake_organization_url", "site_collection.path": "fake_site_collection_path", "client_secret": "fake_client_secret", "public_key_id": "fake_public_key_id", "private_key": "fake_private_key", "passphrase": "fake_passphrase", "password": "fake_password", "gateway_id": "fake_gateway_id", "source_version": "fake_source_version", "web_application_url": "fake_web_application_url", "domain": "fake_domain", "endpoint": "fake_endpoint", "access_key_id": "fake_access_key_id", "secret_access_key": "fake_secret_access_key"}""" - )), - "status": - "string1", - }) + body.update({"source_type": "string1", "credential_details": CredentialDetails._from_dict(json.loads("""{"credential_type": "fake_credential_type", "client_id": "fake_client_id", "enterprise_id": "fake_enterprise_id", "url": "fake_url", "username": "fake_username", "organization_url": "fake_organization_url", "site_collection.path": "fake_site_collection_path", "client_secret": "fake_client_secret", "public_key_id": "fake_public_key_id", "private_key": "fake_private_key", "passphrase": "fake_passphrase", "password": "fake_password", "gateway_id": "fake_gateway_id", "source_version": "fake_source_version", "web_application_url": "fake_web_application_url", "domain": "fake_domain", "endpoint": "fake_endpoint", "access_key_id": "fake_access_key_id", "secret_access_key": "fake_secret_access_key"}""")), "status": "string1", }) return body @@ -4473,23 +4176,22 @@ def test_get_credentials_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/credentials/{1}'.format( - body['environment_id'], body['credential_id']) + endpoint = '/v1/environments/{0}/credentials/{1}'.format(body['environment_id'], body['credential_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.get_credentials(**body) return output @@ -4546,23 +4248,22 @@ def test_update_credentials_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/credentials/{1}'.format( - body['environment_id'], body['credential_id']) + endpoint = '/v1/environments/{0}/credentials/{1}'.format(body['environment_id'], body['credential_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.PUT, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.update_credentials(**body) return output @@ -4571,34 +4272,14 @@ def construct_full_body(self): body = dict() body['environment_id'] = "string1" body['credential_id'] = "string1" - body.update({ - "source_type": - "string1", - "credential_details": - CredentialDetails._from_dict( - json.loads( - """{"credential_type": "fake_credential_type", "client_id": "fake_client_id", "enterprise_id": "fake_enterprise_id", "url": "fake_url", "username": "fake_username", "organization_url": "fake_organization_url", "site_collection.path": "fake_site_collection_path", "client_secret": "fake_client_secret", "public_key_id": "fake_public_key_id", "private_key": "fake_private_key", "passphrase": "fake_passphrase", "password": "fake_password", "gateway_id": "fake_gateway_id", "source_version": "fake_source_version", "web_application_url": "fake_web_application_url", "domain": "fake_domain", "endpoint": "fake_endpoint", "access_key_id": "fake_access_key_id", "secret_access_key": "fake_secret_access_key"}""" - )), - "status": - "string1", - }) + body.update({"source_type": "string1", "credential_details": CredentialDetails._from_dict(json.loads("""{"credential_type": "fake_credential_type", "client_id": "fake_client_id", "enterprise_id": "fake_enterprise_id", "url": "fake_url", "username": "fake_username", "organization_url": "fake_organization_url", "site_collection.path": "fake_site_collection_path", "client_secret": "fake_client_secret", "public_key_id": "fake_public_key_id", "private_key": "fake_private_key", "passphrase": "fake_passphrase", "password": "fake_password", "gateway_id": "fake_gateway_id", "source_version": "fake_source_version", "web_application_url": "fake_web_application_url", "domain": "fake_domain", "endpoint": "fake_endpoint", "access_key_id": "fake_access_key_id", "secret_access_key": "fake_secret_access_key"}""")), "status": "string1", }) return body def construct_required_body(self): body = dict() body['environment_id'] = "string1" body['credential_id'] = "string1" - body.update({ - "source_type": - "string1", - "credential_details": - CredentialDetails._from_dict( - json.loads( - """{"credential_type": "fake_credential_type", "client_id": "fake_client_id", "enterprise_id": "fake_enterprise_id", "url": "fake_url", "username": "fake_username", "organization_url": "fake_organization_url", "site_collection.path": "fake_site_collection_path", "client_secret": "fake_client_secret", "public_key_id": "fake_public_key_id", "private_key": "fake_private_key", "passphrase": "fake_passphrase", "password": "fake_password", "gateway_id": "fake_gateway_id", "source_version": "fake_source_version", "web_application_url": "fake_web_application_url", "domain": "fake_domain", "endpoint": "fake_endpoint", "access_key_id": "fake_access_key_id", "secret_access_key": "fake_secret_access_key"}""" - )), - "status": - "string1", - }) + body.update({"source_type": "string1", "credential_details": CredentialDetails._from_dict(json.loads("""{"credential_type": "fake_credential_type", "client_id": "fake_client_id", "enterprise_id": "fake_enterprise_id", "url": "fake_url", "username": "fake_username", "organization_url": "fake_organization_url", "site_collection.path": "fake_site_collection_path", "client_secret": "fake_client_secret", "public_key_id": "fake_public_key_id", "private_key": "fake_private_key", "passphrase": "fake_passphrase", "password": "fake_password", "gateway_id": "fake_gateway_id", "source_version": "fake_source_version", "web_application_url": "fake_web_application_url", "domain": "fake_domain", "endpoint": "fake_endpoint", "access_key_id": "fake_access_key_id", "secret_access_key": "fake_secret_access_key"}""")), "status": "string1", }) return body @@ -4641,23 +4322,22 @@ def test_delete_credentials_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/credentials/{1}'.format( - body['environment_id'], body['credential_id']) + endpoint = '/v1/environments/{0}/credentials/{1}'.format(body['environment_id'], body['credential_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.delete_credentials(**body) return output @@ -4685,7 +4365,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_gateways #----------------------------------------------------------------------------- @@ -4725,23 +4404,22 @@ def test_list_gateways_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/gateways'.format( - body['environment_id']) + endpoint = '/v1/environments/{0}/gateways'.format(body['environment_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.list_gateways(**body) return output @@ -4796,23 +4474,22 @@ def test_create_gateway_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/gateways'.format( - body['environment_id']) + endpoint = '/v1/environments/{0}/gateways'.format(body['environment_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.create_gateway(**body) return output @@ -4820,9 +4497,7 @@ def call_service(self, body): def construct_full_body(self): body = dict() body['environment_id'] = "string1" - body.update({ - "name": "string1", - }) + body.update({"name": "string1", }) return body def construct_required_body(self): @@ -4870,23 +4545,22 @@ def test_get_gateway_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/gateways/{1}'.format( - body['environment_id'], body['gateway_id']) + endpoint = '/v1/environments/{0}/gateways/{1}'.format(body['environment_id'], body['gateway_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.get_gateway(**body) return output @@ -4943,23 +4617,22 @@ def test_delete_gateway_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/environments/{0}/gateways/{1}'.format( - body['environment_id'], body['gateway_id']) + endpoint = '/v1/environments/{0}/gateways/{1}'.format(body['environment_id'], body['gateway_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV1( authenticator=NoAuthAuthenticator(), version='2019-04-30', - ) + ) service.set_service_url(base_url) output = service.delete_gateway(**body) return output @@ -4999,7 +4672,6 @@ def check_empty_required_params(obj, response): error = True assert error - def check_missing_required_params(obj): """Test function to assert that the operation will throw an error when missing required data @@ -5016,7 +4688,6 @@ def check_missing_required_params(obj): error = True assert error - def check_empty_response(obj): """Test function to assert that the operation will return an empty response when given an empty request @@ -5028,7 +4699,6 @@ def check_empty_response(obj): url = obj.make_url(body) send_request(obj, {}, {}, url=url) - def send_request(obj, body, response, url=None): """Test function to create a request, send it, and assert its accuracy to the mock response @@ -5045,16 +4715,15 @@ def send_request(obj, body, response, url=None): assert responses.calls[0].request.url.startswith(url) assert output.get_result() == response - #################### ## Mock Responses ## #################### fake_response__json = None -fake_response_Environment_json = """{"environment_id": "fake_environment_id", "name": "fake_name", "description": "fake_description", "created": "2017-05-16T13:56:54.957Z", "updated": "2017-05-16T13:56:54.957Z", "status": "fake_status", "read_only": false, "size": "fake_size", "requested_size": "fake_requested_size", "index_capacity": {"documents": {"indexed": 7, "maximum_allowed": 15}, "disk_usage": {"used_bytes": 10, "maximum_allowed_bytes": 21}, "collections": {"available": 9, "maximum_allowed": 15}}, "search_status": {"scope": "fake_scope", "status": "fake_status", "status_description": "fake_status_description"}}""" +fake_response_Environment_json = """{"environment_id": "fake_environment_id", "name": "fake_name", "description": "fake_description", "created": "2017-05-16T13:56:54.957Z", "updated": "2017-05-16T13:56:54.957Z", "status": "fake_status", "read_only": false, "size": "fake_size", "requested_size": "fake_requested_size", "index_capacity": {"documents": {"available": 9, "maximum_allowed": 15}, "disk_usage": {"used_bytes": 10, "maximum_allowed_bytes": 21}, "collections": {"available": 9, "maximum_allowed": 15}}, "search_status": {"scope": "fake_scope", "status": "fake_status", "status_description": "fake_status_description"}}""" fake_response_ListEnvironmentsResponse_json = """{"environments": []}""" -fake_response_Environment_json = """{"environment_id": "fake_environment_id", "name": "fake_name", "description": "fake_description", "created": "2017-05-16T13:56:54.957Z", "updated": "2017-05-16T13:56:54.957Z", "status": "fake_status", "read_only": false, "size": "fake_size", "requested_size": "fake_requested_size", "index_capacity": {"documents": {"indexed": 7, "maximum_allowed": 15}, "disk_usage": {"used_bytes": 10, "maximum_allowed_bytes": 21}, "collections": {"available": 9, "maximum_allowed": 15}}, "search_status": {"scope": "fake_scope", "status": "fake_status", "status_description": "fake_status_description"}}""" -fake_response_Environment_json = """{"environment_id": "fake_environment_id", "name": "fake_name", "description": "fake_description", "created": "2017-05-16T13:56:54.957Z", "updated": "2017-05-16T13:56:54.957Z", "status": "fake_status", "read_only": false, "size": "fake_size", "requested_size": "fake_requested_size", "index_capacity": {"documents": {"indexed": 7, "maximum_allowed": 15}, "disk_usage": {"used_bytes": 10, "maximum_allowed_bytes": 21}, "collections": {"available": 9, "maximum_allowed": 15}}, "search_status": {"scope": "fake_scope", "status": "fake_status", "status_description": "fake_status_description"}}""" +fake_response_Environment_json = """{"environment_id": "fake_environment_id", "name": "fake_name", "description": "fake_description", "created": "2017-05-16T13:56:54.957Z", "updated": "2017-05-16T13:56:54.957Z", "status": "fake_status", "read_only": false, "size": "fake_size", "requested_size": "fake_requested_size", "index_capacity": {"documents": {"available": 9, "maximum_allowed": 15}, "disk_usage": {"used_bytes": 10, "maximum_allowed_bytes": 21}, "collections": {"available": 9, "maximum_allowed": 15}}, "search_status": {"scope": "fake_scope", "status": "fake_status", "status_description": "fake_status_description"}}""" +fake_response_Environment_json = """{"environment_id": "fake_environment_id", "name": "fake_name", "description": "fake_description", "created": "2017-05-16T13:56:54.957Z", "updated": "2017-05-16T13:56:54.957Z", "status": "fake_status", "read_only": false, "size": "fake_size", "requested_size": "fake_requested_size", "index_capacity": {"documents": {"available": 9, "maximum_allowed": 15}, "disk_usage": {"used_bytes": 10, "maximum_allowed_bytes": 21}, "collections": {"available": 9, "maximum_allowed": 15}}, "search_status": {"scope": "fake_scope", "status": "fake_status", "status_description": "fake_status_description"}}""" fake_response_DeleteEnvironmentResponse_json = """{"environment_id": "fake_environment_id", "status": "fake_status"}""" fake_response_ListCollectionFieldsResponse_json = """{"fields": []}""" fake_response_Configuration_json = """{"configuration_id": "fake_configuration_id", "name": "fake_name", "created": "2017-05-16T13:56:54.957Z", "updated": "2017-05-16T13:56:54.957Z", "description": "fake_description", "conversions": {"pdf": {"heading": {"fonts": []}}, "word": {"heading": {"fonts": [], "styles": []}}, "html": {"exclude_tags_completely": [], "exclude_tags_keep_content": [], "keep_content": {"xpaths": []}, "exclude_content": {"xpaths": []}, "keep_tag_attributes": [], "exclude_tag_attributes": []}, "segment": {"enabled": false, "selector_tags": [], "annotated_fields": []}, "json_normalizations": [], "image_text_recognition": true}, "enrichments": [], "normalizations": [], "source": {"type": "fake_type", "credential_id": "fake_credential_id", "schedule": {"enabled": false, "time_zone": "fake_time_zone", "frequency": "fake_frequency"}, "options": {"folders": [], "objects": [], "site_collections": [], "urls": [], "buckets": [], "crawl_all_buckets": false}}}""" diff --git a/test/unit/test_discovery_v2.py b/test/unit/test_discovery_v2.py index 12cdef354..d5f320933 100644 --- a/test/unit/test_discovery_v2.py +++ b/test/unit/test_discovery_v2.py @@ -30,7 +30,6 @@ ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_collections #----------------------------------------------------------------------------- @@ -62,8 +61,7 @@ def test_list_collections_required_response(self): #-------------------------------------------------------- @responses.activate def test_list_collections_empty(self): - check_empty_required_params(self, - fake_response_ListCollectionsResponse_json) + check_empty_required_params(self, fake_response_ListCollectionsResponse_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -77,16 +75,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV2( authenticator=NoAuthAuthenticator(), version='2019-11-22', - ) + ) service.set_service_url(base_url) output = service.list_collections(**body) return output @@ -112,7 +110,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for query #----------------------------------------------------------------------------- @@ -158,16 +155,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV2( authenticator=NoAuthAuthenticator(), version='2019-11-22', - ) + ) service.set_service_url(base_url) output = service.query(**body) return output @@ -175,39 +172,7 @@ def call_service(self, body): def construct_full_body(self): body = dict() body['project_id'] = "string1" - body.update({ - "collection_ids": [], - "filter": - "string1", - "query": - "string1", - "natural_language_query": - "string1", - "aggregation": - "string1", - "count": - 12345, - "return_": [], - "offset": - 12345, - "sort": - "string1", - "highlight": - True, - "spelling_suggestions": - True, - "table_results": - QueryLargeTableResults._from_dict( - json.loads("""{"enabled": false, "count": 5}""")), - "suggested_refinements": - QueryLargeSuggestedRefinements._from_dict( - json.loads("""{"enabled": false, "count": 5}""")), - "passages": - QueryLargePassages._from_dict( - json.loads( - """{"enabled": false, "per_document": true, "max_per_document": 16, "fields": [], "count": 5, "characters": 10}""" - )), - }) + body.update({"collection_ids": [], "filter": "string1", "query": "string1", "natural_language_query": "string1", "aggregation": "string1", "count": 12345, "return_": [], "offset": 12345, "sort": "string1", "highlight": True, "spelling_suggestions": True, "table_results": QueryLargeTableResults._from_dict(json.loads("""{"enabled": false, "count": 5}""")), "suggested_refinements": QueryLargeSuggestedRefinements._from_dict(json.loads("""{"enabled": false, "count": 5}""")), "passages": QueryLargePassages._from_dict(json.loads("""{"enabled": false, "per_document": true, "max_per_document": 16, "fields": [], "count": 5, "characters": 10}""")), }) return body def construct_required_body(self): @@ -261,16 +226,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV2( authenticator=NoAuthAuthenticator(), version='2019-11-22', - ) + ) service.set_service_url(base_url) output = service.get_autocompletion(**body) return output @@ -322,8 +287,7 @@ def test_query_notices_required_response(self): #-------------------------------------------------------- @responses.activate def test_query_notices_empty(self): - check_empty_required_params(self, - fake_response_QueryNoticesResponse_json) + check_empty_required_params(self, fake_response_QueryNoticesResponse_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -337,16 +301,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV2( authenticator=NoAuthAuthenticator(), version='2019-11-22', - ) + ) service.set_service_url(base_url) output = service.query_notices(**body) return output @@ -412,16 +376,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV2( authenticator=NoAuthAuthenticator(), version='2019-11-22', - ) + ) service.set_service_url(base_url) output = service.list_fields(**body) return output @@ -448,7 +412,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for get_component_settings #----------------------------------------------------------------------------- @@ -480,8 +443,7 @@ def test_get_component_settings_required_response(self): #-------------------------------------------------------- @responses.activate def test_get_component_settings_empty(self): - check_empty_required_params( - self, fake_response_ComponentSettingsResponse_json) + check_empty_required_params(self, fake_response_ComponentSettingsResponse_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -489,23 +451,22 @@ def test_get_component_settings_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v2/projects/{0}/component_settings'.format( - body['project_id']) + endpoint = '/v2/projects/{0}/component_settings'.format(body['project_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV2( authenticator=NoAuthAuthenticator(), version='2019-11-22', - ) + ) service.set_service_url(base_url) output = service.get_component_settings(**body) return output @@ -531,7 +492,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for add_document #----------------------------------------------------------------------------- @@ -571,23 +531,22 @@ def test_add_document_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v2/projects/{0}/collections/{1}/documents'.format( - body['project_id'], body['collection_id']) + endpoint = '/v2/projects/{0}/collections/{1}/documents'.format(body['project_id'], body['collection_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=202, - content_type='application/json') - + url, + body=json.dumps(response), + status=202, + content_type='application/json') + def call_service(self, body): service = DiscoveryV2( authenticator=NoAuthAuthenticator(), version='2019-11-22', - ) + ) service.set_service_url(base_url) output = service.add_document(**body) return output @@ -649,23 +608,22 @@ def test_update_document_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v2/projects/{0}/collections/{1}/documents/{2}'.format( - body['project_id'], body['collection_id'], body['document_id']) + endpoint = '/v2/projects/{0}/collections/{1}/documents/{2}'.format(body['project_id'], body['collection_id'], body['document_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=202, - content_type='application/json') - + url, + body=json.dumps(response), + status=202, + content_type='application/json') + def call_service(self, body): service = DiscoveryV2( authenticator=NoAuthAuthenticator(), version='2019-11-22', - ) + ) service.set_service_url(base_url) output = service.update_document(**body) return output @@ -721,8 +679,7 @@ def test_delete_document_required_response(self): #-------------------------------------------------------- @responses.activate def test_delete_document_empty(self): - check_empty_required_params(self, - fake_response_DeleteDocumentResponse_json) + check_empty_required_params(self, fake_response_DeleteDocumentResponse_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -730,23 +687,22 @@ def test_delete_document_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v2/projects/{0}/collections/{1}/documents/{2}'.format( - body['project_id'], body['collection_id'], body['document_id']) + endpoint = '/v2/projects/{0}/collections/{1}/documents/{2}'.format(body['project_id'], body['collection_id'], body['document_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV2( authenticator=NoAuthAuthenticator(), version='2019-11-22', - ) + ) service.set_service_url(base_url) output = service.delete_document(**body) return output @@ -777,7 +733,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_training_queries #----------------------------------------------------------------------------- @@ -817,23 +772,22 @@ def test_list_training_queries_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v2/projects/{0}/training_data/queries'.format( - body['project_id']) + endpoint = '/v2/projects/{0}/training_data/queries'.format(body['project_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV2( authenticator=NoAuthAuthenticator(), version='2019-11-22', - ) + ) service.set_service_url(base_url) output = service.list_training_queries(**body) return output @@ -888,23 +842,22 @@ def test_delete_training_queries_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v2/projects/{0}/training_data/queries'.format( - body['project_id']) + endpoint = '/v2/projects/{0}/training_data/queries'.format(body['project_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=204, - content_type='') - + url, + body=json.dumps(response), + status=204, + content_type='') + def call_service(self, body): service = DiscoveryV2( authenticator=NoAuthAuthenticator(), version='2019-11-22', - ) + ) service.set_service_url(base_url) output = service.delete_training_queries(**body) return output @@ -959,23 +912,22 @@ def test_create_training_query_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v2/projects/{0}/training_data/queries'.format( - body['project_id']) + endpoint = '/v2/projects/{0}/training_data/queries'.format(body['project_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=201, - content_type='application/json') - + url, + body=json.dumps(response), + status=201, + content_type='application/json') + def call_service(self, body): service = DiscoveryV2( authenticator=NoAuthAuthenticator(), version='2019-11-22', - ) + ) service.set_service_url(base_url) output = service.create_training_query(**body) return output @@ -983,21 +935,13 @@ def call_service(self, body): def construct_full_body(self): body = dict() body['project_id'] = "string1" - body.update({ - "natural_language_query": "string1", - "examples": [], - "filter": "string1", - }) + body.update({"natural_language_query": "string1", "examples": [], "filter": "string1", }) return body def construct_required_body(self): body = dict() body['project_id'] = "string1" - body.update({ - "natural_language_query": "string1", - "examples": [], - "filter": "string1", - }) + body.update({"natural_language_query": "string1", "examples": [], "filter": "string1", }) return body @@ -1040,23 +984,22 @@ def test_get_training_query_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v2/projects/{0}/training_data/queries/{1}'.format( - body['project_id'], body['query_id']) + endpoint = '/v2/projects/{0}/training_data/queries/{1}'.format(body['project_id'], body['query_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = DiscoveryV2( authenticator=NoAuthAuthenticator(), version='2019-11-22', - ) + ) service.set_service_url(base_url) output = service.get_training_query(**body) return output @@ -1113,23 +1056,22 @@ def test_update_training_query_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v2/projects/{0}/training_data/queries/{1}'.format( - body['project_id'], body['query_id']) + endpoint = '/v2/projects/{0}/training_data/queries/{1}'.format(body['project_id'], body['query_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=201, - content_type='application/json') - + url, + body=json.dumps(response), + status=201, + content_type='application/json') + def call_service(self, body): service = DiscoveryV2( authenticator=NoAuthAuthenticator(), version='2019-11-22', - ) + ) service.set_service_url(base_url) output = service.update_training_query(**body) return output @@ -1138,22 +1080,14 @@ def construct_full_body(self): body = dict() body['project_id'] = "string1" body['query_id'] = "string1" - body.update({ - "natural_language_query": "string1", - "examples": [], - "filter": "string1", - }) + body.update({"natural_language_query": "string1", "examples": [], "filter": "string1", }) return body def construct_required_body(self): body = dict() body['project_id'] = "string1" body['query_id'] = "string1" - body.update({ - "natural_language_query": "string1", - "examples": [], - "filter": "string1", - }) + body.update({"natural_language_query": "string1", "examples": [], "filter": "string1", }) return body @@ -1179,7 +1113,6 @@ def check_empty_required_params(obj, response): error = True assert error - def check_missing_required_params(obj): """Test function to assert that the operation will throw an error when missing required data @@ -1196,7 +1129,6 @@ def check_missing_required_params(obj): error = True assert error - def check_empty_response(obj): """Test function to assert that the operation will return an empty response when given an empty request @@ -1208,7 +1140,6 @@ def check_empty_response(obj): url = obj.make_url(body) send_request(obj, {}, {}, url=url) - def send_request(obj, body, response, url=None): """Test function to create a request, send it, and assert its accuracy to the mock response @@ -1225,7 +1156,6 @@ def send_request(obj, body, response, url=None): assert responses.calls[0].request.url.startswith(url) assert output.get_result() == response - #################### ## Mock Responses ## #################### diff --git a/test/unit/test_language_translator_v3.py b/test/unit/test_language_translator_v3.py index f0a4f3098..65586dff3 100644 --- a/test/unit/test_language_translator_v3.py +++ b/test/unit/test_language_translator_v3.py @@ -30,7 +30,6 @@ ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for translate #----------------------------------------------------------------------------- @@ -76,38 +75,28 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = LanguageTranslatorV3( authenticator=NoAuthAuthenticator(), version='2018-05-01', - ) + ) service.set_service_url(base_url) output = service.translate(**body) return output def construct_full_body(self): body = dict() - body.update({ - "text": [], - "model_id": "string1", - "source": "string1", - "target": "string1", - }) + body.update({"text": [], "model_id": "string1", "source": "string1", "target": "string1", }) return body def construct_required_body(self): body = dict() - body.update({ - "text": [], - "model_id": "string1", - "source": "string1", - "target": "string1", - }) + body.update({"text": [], "model_id": "string1", "source": "string1", "target": "string1", }) return body @@ -121,7 +110,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_identifiable_languages #----------------------------------------------------------------------------- @@ -166,16 +154,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = LanguageTranslatorV3( authenticator=NoAuthAuthenticator(), version='2018-05-01', - ) + ) service.set_service_url(base_url) output = service.list_identifiable_languages(**body) return output @@ -220,8 +208,7 @@ def test_identify_required_response(self): #-------------------------------------------------------- @responses.activate def test_identify_empty(self): - check_empty_required_params(self, - fake_response_IdentifiedLanguages_json) + check_empty_required_params(self, fake_response_IdentifiedLanguages_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -235,16 +222,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = LanguageTranslatorV3( authenticator=NoAuthAuthenticator(), version='2018-05-01', - ) + ) service.set_service_url(base_url) output = service.identify(**body) return output @@ -270,7 +257,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_models #----------------------------------------------------------------------------- @@ -315,16 +301,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = LanguageTranslatorV3( authenticator=NoAuthAuthenticator(), version='2018-05-01', - ) + ) service.set_service_url(base_url) output = service.list_models(**body) return output @@ -386,16 +372,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = LanguageTranslatorV3( authenticator=NoAuthAuthenticator(), version='2018-05-01', - ) + ) service.set_service_url(base_url) output = service.create_model(**body) return output @@ -459,16 +445,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = LanguageTranslatorV3( authenticator=NoAuthAuthenticator(), version='2018-05-01', - ) + ) service.set_service_url(base_url) output = service.delete_model(**body) return output @@ -529,16 +515,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = LanguageTranslatorV3( authenticator=NoAuthAuthenticator(), version='2018-05-01', - ) + ) service.set_service_url(base_url) output = service.get_model(**body) return output @@ -564,7 +550,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_documents #----------------------------------------------------------------------------- @@ -609,16 +594,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = LanguageTranslatorV3( authenticator=NoAuthAuthenticator(), version='2018-05-01', - ) + ) service.set_service_url(base_url) output = service.list_documents(**body) return output @@ -677,16 +662,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=202, - content_type='application/json') - + url, + body=json.dumps(response), + status=202, + content_type='application/json') + def call_service(self, body): service = LanguageTranslatorV3( authenticator=NoAuthAuthenticator(), version='2018-05-01', - ) + ) service.set_service_url(base_url) output = service.translate_document(**body) return output @@ -753,16 +738,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = LanguageTranslatorV3( authenticator=NoAuthAuthenticator(), version='2018-05-01', - ) + ) service.set_service_url(base_url) output = service.get_document_status(**body) return output @@ -823,16 +808,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=204, - content_type='') - + url, + body=json.dumps(response), + status=204, + content_type='') + def call_service(self, body): service = LanguageTranslatorV3( authenticator=NoAuthAuthenticator(), version='2018-05-01', - ) + ) service.set_service_url(base_url) output = service.delete_document(**body) return output @@ -887,23 +872,22 @@ def test_get_translated_document_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v3/documents/{0}/translated_document'.format( - body['document_id']) + endpoint = '/v3/documents/{0}/translated_document'.format(body['document_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): service = LanguageTranslatorV3( authenticator=NoAuthAuthenticator(), version='2018-05-01', - ) + ) service.set_service_url(base_url) output = service.get_translated_document(**body) return output @@ -942,7 +926,6 @@ def check_empty_required_params(obj, response): error = True assert error - def check_missing_required_params(obj): """Test function to assert that the operation will throw an error when missing required data @@ -959,7 +942,6 @@ def check_missing_required_params(obj): error = True assert error - def check_empty_response(obj): """Test function to assert that the operation will return an empty response when given an empty request @@ -971,7 +953,6 @@ def check_empty_response(obj): url = obj.make_url(body) send_request(obj, {}, {}, url=url) - def send_request(obj, body, response, url=None): """Test function to create a request, send it, and assert its accuracy to the mock response @@ -988,13 +969,12 @@ def send_request(obj, body, response, url=None): assert responses.calls[0].request.url.startswith(url) assert output.get_result() == response - #################### ## Mock Responses ## #################### fake_response__json = None -fake_response_TranslationResult_json = """{"word_count": 10, "character_count": 15, "translations": []}""" +fake_response_TranslationResult_json = """{"word_count": 10, "character_count": 15, "detected_language": "fake_detected_language", "detected_language_confidence": 28, "translations": []}""" fake_response_IdentifiableLanguages_json = """{"languages": []}""" fake_response_IdentifiedLanguages_json = """{"languages": []}""" fake_response_TranslationModels_json = """{"models": []}""" @@ -1002,6 +982,6 @@ def send_request(obj, body, response, url=None): fake_response_DeleteModelResult_json = """{"status": "fake_status"}""" fake_response_TranslationModel_json = """{"model_id": "fake_model_id", "name": "fake_name", "source": "fake_source", "target": "fake_target", "base_model_id": "fake_base_model_id", "domain": "fake_domain", "customizable": true, "default_model": false, "owner": "fake_owner", "status": "fake_status"}""" fake_response_DocumentList_json = """{"documents": []}""" -fake_response_DocumentStatus_json = """{"document_id": "fake_document_id", "filename": "fake_filename", "status": "fake_status", "model_id": "fake_model_id", "base_model_id": "fake_base_model_id", "source": "fake_source", "target": "fake_target", "created": "2017-05-16T13:56:54.957Z", "completed": "2017-05-16T13:56:54.957Z", "word_count": 10, "character_count": 15}""" -fake_response_DocumentStatus_json = """{"document_id": "fake_document_id", "filename": "fake_filename", "status": "fake_status", "model_id": "fake_model_id", "base_model_id": "fake_base_model_id", "source": "fake_source", "target": "fake_target", "created": "2017-05-16T13:56:54.957Z", "completed": "2017-05-16T13:56:54.957Z", "word_count": 10, "character_count": 15}""" +fake_response_DocumentStatus_json = """{"document_id": "fake_document_id", "filename": "fake_filename", "status": "fake_status", "model_id": "fake_model_id", "base_model_id": "fake_base_model_id", "source": "fake_source", "detected_language_confidence": 28, "target": "fake_target", "created": "2017-05-16T13:56:54.957Z", "completed": "2017-05-16T13:56:54.957Z", "word_count": 10, "character_count": 15}""" +fake_response_DocumentStatus_json = """{"document_id": "fake_document_id", "filename": "fake_filename", "status": "fake_status", "model_id": "fake_model_id", "base_model_id": "fake_base_model_id", "source": "fake_source", "detected_language_confidence": 28, "target": "fake_target", "created": "2017-05-16T13:56:54.957Z", "completed": "2017-05-16T13:56:54.957Z", "word_count": 10, "character_count": 15}""" fake_response_BinaryIO_json = """Contents of response byte-stream...""" diff --git a/test/unit/test_natural_language_classifier_v1.py b/test/unit/test_natural_language_classifier_v1.py index 105fe8264..3c142ef6c 100644 --- a/test/unit/test_natural_language_classifier_v1.py +++ b/test/unit/test_natural_language_classifier_v1.py @@ -30,7 +30,6 @@ ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for classify #----------------------------------------------------------------------------- @@ -76,14 +75,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = NaturalLanguageClassifierV1( - authenticator=NoAuthAuthenticator(),) + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.classify(**body) return output @@ -91,17 +91,13 @@ def call_service(self, body): def construct_full_body(self): body = dict() body['classifier_id'] = "string1" - body.update({ - "text": "string1", - }) + body.update({"text": "string1", }) return body def construct_required_body(self): body = dict() body['classifier_id'] = "string1" - body.update({ - "text": "string1", - }) + body.update({"text": "string1", }) return body @@ -136,8 +132,7 @@ def test_classify_collection_required_response(self): #-------------------------------------------------------- @responses.activate def test_classify_collection_empty(self): - check_empty_required_params( - self, fake_response_ClassificationCollection_json) + check_empty_required_params(self, fake_response_ClassificationCollection_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -145,21 +140,21 @@ def test_classify_collection_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/classifiers/{0}/classify_collection'.format( - body['classifier_id']) + endpoint = '/v1/classifiers/{0}/classify_collection'.format(body['classifier_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = NaturalLanguageClassifierV1( - authenticator=NoAuthAuthenticator(),) + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.classify_collection(**body) return output @@ -167,17 +162,13 @@ def call_service(self, body): def construct_full_body(self): body = dict() body['classifier_id'] = "string1" - body.update({ - "collection": [], - }) + body.update({"collection": [], }) return body def construct_required_body(self): body = dict() body['classifier_id'] = "string1" - body.update({ - "collection": [], - }) + body.update({"collection": [], }) return body @@ -191,7 +182,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for create_classifier #----------------------------------------------------------------------------- @@ -237,14 +227,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = NaturalLanguageClassifierV1( - authenticator=NoAuthAuthenticator(),) + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.create_classifier(**body) return output @@ -306,14 +297,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = NaturalLanguageClassifierV1( - authenticator=NoAuthAuthenticator(),) + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.list_classifiers(**body) return output @@ -372,14 +364,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = NaturalLanguageClassifierV1( - authenticator=NoAuthAuthenticator(),) + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.get_classifier(**body) return output @@ -440,14 +433,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): service = NaturalLanguageClassifierV1( - authenticator=NoAuthAuthenticator(),) + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.delete_classifier(**body) return output @@ -485,7 +479,6 @@ def check_empty_required_params(obj, response): error = True assert error - def check_missing_required_params(obj): """Test function to assert that the operation will throw an error when missing required data @@ -502,7 +495,6 @@ def check_missing_required_params(obj): error = True assert error - def check_empty_response(obj): """Test function to assert that the operation will return an empty response when given an empty request @@ -514,7 +506,6 @@ def check_empty_response(obj): url = obj.make_url(body) send_request(obj, {}, {}, url=url) - def send_request(obj, body, response, url=None): """Test function to create a request, send it, and assert its accuracy to the mock response @@ -531,7 +522,6 @@ def send_request(obj, body, response, url=None): assert responses.calls[0].request.url.startswith(url) assert output.get_result() == response - #################### ## Mock Responses ## #################### diff --git a/test/unit/test_natural_language_understanding_v1.py b/test/unit/test_natural_language_understanding_v1.py index 18f6b0a08..0857daea3 100644 --- a/test/unit/test_natural_language_understanding_v1.py +++ b/test/unit/test_natural_language_understanding_v1.py @@ -29,7 +29,6 @@ ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for analyze #----------------------------------------------------------------------------- @@ -75,76 +74,28 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = NaturalLanguageUnderstandingV1( authenticator=NoAuthAuthenticator(), version='2019-07-12', - ) + ) service.set_service_url(base_url) output = service.analyze(**body) return output def construct_full_body(self): body = dict() - body.update({ - "features": - Features._from_dict( - json.loads( - """{"concepts": {"limit": 5}, "emotion": {"document": true, "targets": []}, "entities": {"limit": 5, "mentions": true, "model": "fake_model", "sentiment": false, "emotion": false}, "keywords": {"limit": 5, "sentiment": false, "emotion": false}, "metadata": {}, "relations": {"model": "fake_model"}, "semantic_roles": {"limit": 5, "keywords": true, "entities": true}, "sentiment": {"document": true, "targets": []}, "categories": {"explanation": false, "limit": 5, "model": "fake_model"}, "syntax": {"tokens": {"lemma": false, "part_of_speech": true}, "sentences": false}}""" - )), - "text": - "string1", - "html": - "string1", - "url": - "string1", - "clean": - True, - "xpath": - "string1", - "fallback_to_raw": - True, - "return_analyzed_text": - True, - "language": - "string1", - "limit_text_characters": - 12345, - }) + body.update({"features": Features._from_dict(json.loads("""{"concepts": {"limit": 5}, "emotion": {"document": true, "targets": []}, "entities": {"limit": 5, "mentions": true, "model": "fake_model", "sentiment": false, "emotion": false}, "keywords": {"limit": 5, "sentiment": false, "emotion": false}, "metadata": {}, "relations": {"model": "fake_model"}, "semantic_roles": {"limit": 5, "keywords": true, "entities": true}, "sentiment": {"document": true, "targets": []}, "categories": {"explanation": false, "limit": 5, "model": "fake_model"}, "syntax": {"tokens": {"lemma": false, "part_of_speech": true}, "sentences": false}}""")), "text": "string1", "html": "string1", "url": "string1", "clean": True, "xpath": "string1", "fallback_to_raw": True, "return_analyzed_text": True, "language": "string1", "limit_text_characters": 12345, }) return body def construct_required_body(self): body = dict() - body.update({ - "features": - Features._from_dict( - json.loads( - """{"concepts": {"limit": 5}, "emotion": {"document": true, "targets": []}, "entities": {"limit": 5, "mentions": true, "model": "fake_model", "sentiment": false, "emotion": false}, "keywords": {"limit": 5, "sentiment": false, "emotion": false}, "metadata": {}, "relations": {"model": "fake_model"}, "semantic_roles": {"limit": 5, "keywords": true, "entities": true}, "sentiment": {"document": true, "targets": []}, "categories": {"explanation": false, "limit": 5, "model": "fake_model"}, "syntax": {"tokens": {"lemma": false, "part_of_speech": true}, "sentences": false}}""" - )), - "text": - "string1", - "html": - "string1", - "url": - "string1", - "clean": - True, - "xpath": - "string1", - "fallback_to_raw": - True, - "return_analyzed_text": - True, - "language": - "string1", - "limit_text_characters": - 12345, - }) + body.update({"features": Features._from_dict(json.loads("""{"concepts": {"limit": 5}, "emotion": {"document": true, "targets": []}, "entities": {"limit": 5, "mentions": true, "model": "fake_model", "sentiment": false, "emotion": false}, "keywords": {"limit": 5, "sentiment": false, "emotion": false}, "metadata": {}, "relations": {"model": "fake_model"}, "semantic_roles": {"limit": 5, "keywords": true, "entities": true}, "sentiment": {"document": true, "targets": []}, "categories": {"explanation": false, "limit": 5, "model": "fake_model"}, "syntax": {"tokens": {"lemma": false, "part_of_speech": true}, "sentences": false}}""")), "text": "string1", "html": "string1", "url": "string1", "clean": True, "xpath": "string1", "fallback_to_raw": True, "return_analyzed_text": True, "language": "string1", "limit_text_characters": 12345, }) return body @@ -158,7 +109,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_models #----------------------------------------------------------------------------- @@ -203,16 +153,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = NaturalLanguageUnderstandingV1( authenticator=NoAuthAuthenticator(), version='2019-07-12', - ) + ) service.set_service_url(base_url) output = service.list_models(**body) return output @@ -271,16 +221,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = NaturalLanguageUnderstandingV1( authenticator=NoAuthAuthenticator(), version='2019-07-12', - ) + ) service.set_service_url(base_url) output = service.delete_model(**body) return output @@ -318,7 +268,6 @@ def check_empty_required_params(obj, response): error = True assert error - def check_missing_required_params(obj): """Test function to assert that the operation will throw an error when missing required data @@ -335,7 +284,6 @@ def check_missing_required_params(obj): error = True assert error - def check_empty_response(obj): """Test function to assert that the operation will return an empty response when given an empty request @@ -347,7 +295,6 @@ def check_empty_response(obj): url = obj.make_url(body) send_request(obj, {}, {}, url=url) - def send_request(obj, body, response, url=None): """Test function to create a request, send it, and assert its accuracy to the mock response @@ -364,7 +311,6 @@ def send_request(obj, body, response, url=None): assert responses.calls[0].request.url.startswith(url) assert output.get_result() == response - #################### ## Mock Responses ## #################### diff --git a/test/unit/test_personality_insights_v3.py b/test/unit/test_personality_insights_v3.py index 22cab9e9f..fe646402f 100755 --- a/test/unit/test_personality_insights_v3.py +++ b/test/unit/test_personality_insights_v3.py @@ -28,7 +28,6 @@ ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for profile #----------------------------------------------------------------------------- @@ -74,16 +73,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = PersonalityInsightsV3( authenticator=NoAuthAuthenticator(), version='2017-10-13', - ) + ) service.set_service_url(base_url) output = service.profile(**body) return output @@ -129,7 +128,6 @@ def check_empty_required_params(obj, response): error = True assert error - def check_missing_required_params(obj): """Test function to assert that the operation will throw an error when missing required data @@ -146,7 +144,6 @@ def check_missing_required_params(obj): error = True assert error - def check_empty_response(obj): """Test function to assert that the operation will return an empty response when given an empty request @@ -158,7 +155,6 @@ def check_empty_response(obj): url = obj.make_url(body) send_request(obj, {}, {}, url=url) - def send_request(obj, body, response, url=None): """Test function to create a request, send it, and assert its accuracy to the mock response @@ -175,7 +171,6 @@ def send_request(obj, body, response, url=None): assert responses.calls[0].request.url.startswith(url) assert output.get_result() == response - #################### ## Mock Responses ## #################### diff --git a/test/unit/test_speech_to_text_v1.py b/test/unit/test_speech_to_text_v1.py index 1cb6cf5b3..8b8aff3e2 100755 --- a/test/unit/test_speech_to_text_v1.py +++ b/test/unit/test_speech_to_text_v1.py @@ -29,7 +29,6 @@ ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_models #----------------------------------------------------------------------------- @@ -74,13 +73,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.list_models(**body) return output @@ -139,13 +140,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.get_model(**body) return output @@ -171,7 +174,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for recognize #----------------------------------------------------------------------------- @@ -203,8 +205,7 @@ def test_recognize_required_response(self): #-------------------------------------------------------- @responses.activate def test_recognize_empty(self): - check_empty_required_params( - self, fake_response_SpeechRecognitionResults_json) + check_empty_required_params(self, fake_response_SpeechRecognitionResults_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -218,13 +219,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.recognize(**body) return output @@ -254,6 +257,8 @@ def construct_full_body(self): body['audio_metrics'] = True body['end_of_phrase_silence_time'] = 12345.0 body['split_transcript_at_phrase_end'] = True + body['speech_detector_sensitivity'] = 12345.0 + body['background_audio_suppression'] = 12345.0 return body def construct_required_body(self): @@ -272,7 +277,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for register_callback #----------------------------------------------------------------------------- @@ -318,13 +322,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.register_callback(**body) return output @@ -386,13 +392,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.unregister_callback(**body) return output @@ -453,13 +461,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=201, - content_type='application/json') - + url, + body=json.dumps(response), + status=201, + content_type='application/json') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.create_job(**body) return output @@ -495,6 +505,8 @@ def construct_full_body(self): body['audio_metrics'] = True body['end_of_phrase_silence_time'] = 12345.0 body['split_transcript_at_phrase_end'] = True + body['speech_detector_sensitivity'] = 12345.0 + body['background_audio_suppression'] = 12345.0 return body def construct_required_body(self): @@ -547,13 +559,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.check_jobs(**body) return output @@ -612,13 +626,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.check_job(**body) return output @@ -679,13 +695,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=204, - content_type='') - + url, + body=json.dumps(response), + status=204, + content_type='') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.delete_job(**body) return output @@ -711,7 +729,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for create_language_model #----------------------------------------------------------------------------- @@ -757,35 +774,27 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=201, - content_type='application/json') - + url, + body=json.dumps(response), + status=201, + content_type='application/json') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.create_language_model(**body) return output def construct_full_body(self): body = dict() - body.update({ - "name": "string1", - "base_model_name": "string1", - "dialect": "string1", - "description": "string1", - }) + body.update({"name": "string1", "base_model_name": "string1", "dialect": "string1", "description": "string1", }) return body def construct_required_body(self): body = dict() - body.update({ - "name": "string1", - "base_model_name": "string1", - "dialect": "string1", - "description": "string1", - }) + body.update({"name": "string1", "base_model_name": "string1", "dialect": "string1", "description": "string1", }) return body @@ -833,13 +842,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.list_language_models(**body) return output @@ -899,13 +910,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.get_language_model(**body) return output @@ -966,13 +979,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.delete_language_model(**body) return output @@ -1027,20 +1042,21 @@ def test_train_language_model_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/customizations/{0}/train'.format( - body['customization_id']) + endpoint = '/v1/customizations/{0}/train'.format(body['customization_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.train_language_model(**body) return output @@ -1097,20 +1113,21 @@ def test_reset_language_model_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/customizations/{0}/reset'.format( - body['customization_id']) + endpoint = '/v1/customizations/{0}/reset'.format(body['customization_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.reset_language_model(**body) return output @@ -1165,20 +1182,21 @@ def test_upgrade_language_model_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/customizations/{0}/upgrade_model'.format( - body['customization_id']) + endpoint = '/v1/customizations/{0}/upgrade_model'.format(body['customization_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.upgrade_language_model(**body) return output @@ -1204,7 +1222,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_corpora #----------------------------------------------------------------------------- @@ -1244,20 +1261,21 @@ def test_list_corpora_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/customizations/{0}/corpora'.format( - body['customization_id']) + endpoint = '/v1/customizations/{0}/corpora'.format(body['customization_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.list_corpora(**body) return output @@ -1312,20 +1330,21 @@ def test_add_corpus_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/customizations/{0}/corpora/{1}'.format( - body['customization_id'], body['corpus_name']) + endpoint = '/v1/customizations/{0}/corpora/{1}'.format(body['customization_id'], body['corpus_name']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=201, - content_type='') - + url, + body=json.dumps(response), + status=201, + content_type='') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.add_corpus(**body) return output @@ -1385,20 +1404,21 @@ def test_get_corpus_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/customizations/{0}/corpora/{1}'.format( - body['customization_id'], body['corpus_name']) + endpoint = '/v1/customizations/{0}/corpora/{1}'.format(body['customization_id'], body['corpus_name']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.get_corpus(**body) return output @@ -1455,20 +1475,21 @@ def test_delete_corpus_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/customizations/{0}/corpora/{1}'.format( - body['customization_id'], body['corpus_name']) + endpoint = '/v1/customizations/{0}/corpora/{1}'.format(body['customization_id'], body['corpus_name']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.delete_corpus(**body) return output @@ -1496,7 +1517,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_words #----------------------------------------------------------------------------- @@ -1536,20 +1556,21 @@ def test_list_words_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/customizations/{0}/words'.format( - body['customization_id']) + endpoint = '/v1/customizations/{0}/words'.format(body['customization_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.list_words(**body) return output @@ -1606,20 +1627,21 @@ def test_add_words_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/customizations/{0}/words'.format( - body['customization_id']) + endpoint = '/v1/customizations/{0}/words'.format(body['customization_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=201, - content_type='') - + url, + body=json.dumps(response), + status=201, + content_type='') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.add_words(**body) return output @@ -1627,17 +1649,13 @@ def call_service(self, body): def construct_full_body(self): body = dict() body['customization_id'] = "string1" - body.update({ - "words": [], - }) + body.update({"words": [], }) return body def construct_required_body(self): body = dict() body['customization_id'] = "string1" - body.update({ - "words": [], - }) + body.update({"words": [], }) return body @@ -1680,20 +1698,21 @@ def test_add_word_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/customizations/{0}/words/{1}'.format( - body['customization_id'], body['word_name']) + endpoint = '/v1/customizations/{0}/words/{1}'.format(body['customization_id'], body['word_name']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.PUT, - url, - body=json.dumps(response), - status=201, - content_type='') - + url, + body=json.dumps(response), + status=201, + content_type='') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.add_word(**body) return output @@ -1702,22 +1721,14 @@ def construct_full_body(self): body = dict() body['customization_id'] = "string1" body['word_name'] = "string1" - body.update({ - "word": "string1", - "sounds_like": [], - "display_as": "string1", - }) + body.update({"word": "string1", "sounds_like": [], "display_as": "string1", }) return body def construct_required_body(self): body = dict() body['customization_id'] = "string1" body['word_name'] = "string1" - body.update({ - "word": "string1", - "sounds_like": [], - "display_as": "string1", - }) + body.update({"word": "string1", "sounds_like": [], "display_as": "string1", }) return body @@ -1760,20 +1771,21 @@ def test_get_word_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/customizations/{0}/words/{1}'.format( - body['customization_id'], body['word_name']) + endpoint = '/v1/customizations/{0}/words/{1}'.format(body['customization_id'], body['word_name']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.get_word(**body) return output @@ -1830,20 +1842,21 @@ def test_delete_word_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/customizations/{0}/words/{1}'.format( - body['customization_id'], body['word_name']) + endpoint = '/v1/customizations/{0}/words/{1}'.format(body['customization_id'], body['word_name']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.delete_word(**body) return output @@ -1871,7 +1884,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_grammars #----------------------------------------------------------------------------- @@ -1911,20 +1923,21 @@ def test_list_grammars_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/customizations/{0}/grammars'.format( - body['customization_id']) + endpoint = '/v1/customizations/{0}/grammars'.format(body['customization_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.list_grammars(**body) return output @@ -1979,20 +1992,21 @@ def test_add_grammar_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/customizations/{0}/grammars/{1}'.format( - body['customization_id'], body['grammar_name']) + endpoint = '/v1/customizations/{0}/grammars/{1}'.format(body['customization_id'], body['grammar_name']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=201, - content_type='') - + url, + body=json.dumps(response), + status=201, + content_type='') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.add_grammar(**body) return output @@ -2054,20 +2068,21 @@ def test_get_grammar_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/customizations/{0}/grammars/{1}'.format( - body['customization_id'], body['grammar_name']) + endpoint = '/v1/customizations/{0}/grammars/{1}'.format(body['customization_id'], body['grammar_name']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.get_grammar(**body) return output @@ -2124,20 +2139,21 @@ def test_delete_grammar_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/customizations/{0}/grammars/{1}'.format( - body['customization_id'], body['grammar_name']) + endpoint = '/v1/customizations/{0}/grammars/{1}'.format(body['customization_id'], body['grammar_name']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.delete_grammar(**body) return output @@ -2165,7 +2181,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for create_acoustic_model #----------------------------------------------------------------------------- @@ -2211,33 +2226,27 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=201, - content_type='application/json') - + url, + body=json.dumps(response), + status=201, + content_type='application/json') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.create_acoustic_model(**body) return output def construct_full_body(self): body = dict() - body.update({ - "name": "string1", - "base_model_name": "string1", - "description": "string1", - }) + body.update({"name": "string1", "base_model_name": "string1", "description": "string1", }) return body def construct_required_body(self): body = dict() - body.update({ - "name": "string1", - "base_model_name": "string1", - "description": "string1", - }) + body.update({"name": "string1", "base_model_name": "string1", "description": "string1", }) return body @@ -2285,13 +2294,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.list_acoustic_models(**body) return output @@ -2345,20 +2356,21 @@ def test_get_acoustic_model_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/acoustic_customizations/{0}'.format( - body['customization_id']) + endpoint = '/v1/acoustic_customizations/{0}'.format(body['customization_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.get_acoustic_model(**body) return output @@ -2413,20 +2425,21 @@ def test_delete_acoustic_model_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/acoustic_customizations/{0}'.format( - body['customization_id']) + endpoint = '/v1/acoustic_customizations/{0}'.format(body['customization_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.delete_acoustic_model(**body) return output @@ -2481,20 +2494,21 @@ def test_train_acoustic_model_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/acoustic_customizations/{0}/train'.format( - body['customization_id']) + endpoint = '/v1/acoustic_customizations/{0}/train'.format(body['customization_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.train_acoustic_model(**body) return output @@ -2550,20 +2564,21 @@ def test_reset_acoustic_model_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/acoustic_customizations/{0}/reset'.format( - body['customization_id']) + endpoint = '/v1/acoustic_customizations/{0}/reset'.format(body['customization_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.reset_acoustic_model(**body) return output @@ -2618,20 +2633,21 @@ def test_upgrade_acoustic_model_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/acoustic_customizations/{0}/upgrade_model'.format( - body['customization_id']) + endpoint = '/v1/acoustic_customizations/{0}/upgrade_model'.format(body['customization_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.upgrade_acoustic_model(**body) return output @@ -2659,7 +2675,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_audio #----------------------------------------------------------------------------- @@ -2699,20 +2714,21 @@ def test_list_audio_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/acoustic_customizations/{0}/audio'.format( - body['customization_id']) + endpoint = '/v1/acoustic_customizations/{0}/audio'.format(body['customization_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.list_audio(**body) return output @@ -2767,20 +2783,21 @@ def test_add_audio_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/acoustic_customizations/{0}/audio/{1}'.format( - body['customization_id'], body['audio_name']) + endpoint = '/v1/acoustic_customizations/{0}/audio/{1}'.format(body['customization_id'], body['audio_name']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=201, - content_type='') - + url, + body=json.dumps(response), + status=201, + content_type='') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.add_audio(**body) return output @@ -2842,20 +2859,21 @@ def test_get_audio_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/acoustic_customizations/{0}/audio/{1}'.format( - body['customization_id'], body['audio_name']) + endpoint = '/v1/acoustic_customizations/{0}/audio/{1}'.format(body['customization_id'], body['audio_name']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.get_audio(**body) return output @@ -2912,20 +2930,21 @@ def test_delete_audio_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/acoustic_customizations/{0}/audio/{1}'.format( - body['customization_id'], body['audio_name']) + endpoint = '/v1/acoustic_customizations/{0}/audio/{1}'.format(body['customization_id'], body['audio_name']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.delete_audio(**body) return output @@ -2953,7 +2972,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for delete_user_data #----------------------------------------------------------------------------- @@ -2999,13 +3017,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): - service = SpeechToTextV1(authenticator=NoAuthAuthenticator(),) + service = SpeechToTextV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.delete_user_data(**body) return output @@ -3043,7 +3063,6 @@ def check_empty_required_params(obj, response): error = True assert error - def check_missing_required_params(obj): """Test function to assert that the operation will throw an error when missing required data @@ -3060,7 +3079,6 @@ def check_missing_required_params(obj): error = True assert error - def check_empty_response(obj): """Test function to assert that the operation will return an empty response when given an empty request @@ -3072,7 +3090,6 @@ def check_empty_response(obj): url = obj.make_url(body) send_request(obj, {}, {}, url=url) - def send_request(obj, body, response, url=None): """Test function to create a request, send it, and assert its accuracy to the mock response @@ -3089,7 +3106,6 @@ def send_request(obj, body, response, url=None): assert responses.calls[0].request.url.startswith(url) assert output.get_result() == response - #################### ## Mock Responses ## #################### diff --git a/test/unit/test_text_to_speech_v1.py b/test/unit/test_text_to_speech_v1.py index 90225cdbb..b9b89e2a7 100644 --- a/test/unit/test_text_to_speech_v1.py +++ b/test/unit/test_text_to_speech_v1.py @@ -28,7 +28,6 @@ ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_voices #----------------------------------------------------------------------------- @@ -73,13 +72,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = TextToSpeechV1(authenticator=NoAuthAuthenticator(),) + service = TextToSpeechV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.list_voices(**body) return output @@ -138,13 +139,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = TextToSpeechV1(authenticator=NoAuthAuthenticator(),) + service = TextToSpeechV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.get_voice(**body) return output @@ -171,7 +174,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for synthesize #----------------------------------------------------------------------------- @@ -217,22 +219,22 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): - service = TextToSpeechV1(authenticator=NoAuthAuthenticator(),) + service = TextToSpeechV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.synthesize(**body) return output def construct_full_body(self): body = dict() - body.update({ - "text": "string1", - }) + body.update({"text": "string1", }) body['accept'] = "string1" body['voice'] = "string1" body['customization_id'] = "string1" @@ -240,9 +242,7 @@ def construct_full_body(self): def construct_required_body(self): body = dict() - body.update({ - "text": "string1", - }) + body.update({"text": "string1", }) return body @@ -256,7 +256,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for get_pronunciation #----------------------------------------------------------------------------- @@ -302,13 +301,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = TextToSpeechV1(authenticator=NoAuthAuthenticator(),) + service = TextToSpeechV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.get_pronunciation(**body) return output @@ -337,7 +338,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for create_voice_model #----------------------------------------------------------------------------- @@ -383,33 +383,27 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=201, - content_type='application/json') - + url, + body=json.dumps(response), + status=201, + content_type='application/json') + def call_service(self, body): - service = TextToSpeechV1(authenticator=NoAuthAuthenticator(),) + service = TextToSpeechV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.create_voice_model(**body) return output def construct_full_body(self): body = dict() - body.update({ - "name": "string1", - "language": "string1", - "description": "string1", - }) + body.update({"name": "string1", "language": "string1", "description": "string1", }) return body def construct_required_body(self): body = dict() - body.update({ - "name": "string1", - "language": "string1", - "description": "string1", - }) + body.update({"name": "string1", "language": "string1", "description": "string1", }) return body @@ -457,13 +451,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = TextToSpeechV1(authenticator=NoAuthAuthenticator(),) + service = TextToSpeechV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.list_voice_models(**body) return output @@ -523,13 +519,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): - service = TextToSpeechV1(authenticator=NoAuthAuthenticator(),) + service = TextToSpeechV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.update_voice_model(**body) return output @@ -537,21 +535,13 @@ def call_service(self, body): def construct_full_body(self): body = dict() body['customization_id'] = "string1" - body.update({ - "name": "string1", - "description": "string1", - "words": [], - }) + body.update({"name": "string1", "description": "string1", "words": [], }) return body def construct_required_body(self): body = dict() body['customization_id'] = "string1" - body.update({ - "name": "string1", - "description": "string1", - "words": [], - }) + body.update({"name": "string1", "description": "string1", "words": [], }) return body @@ -600,13 +590,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = TextToSpeechV1(authenticator=NoAuthAuthenticator(),) + service = TextToSpeechV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.get_voice_model(**body) return output @@ -667,13 +659,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=204, - content_type='') - + url, + body=json.dumps(response), + status=204, + content_type='') + def call_service(self, body): - service = TextToSpeechV1(authenticator=NoAuthAuthenticator(),) + service = TextToSpeechV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.delete_voice_model(**body) return output @@ -699,7 +693,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for add_words #----------------------------------------------------------------------------- @@ -739,20 +732,21 @@ def test_add_words_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/customizations/{0}/words'.format( - body['customization_id']) + endpoint = '/v1/customizations/{0}/words'.format(body['customization_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): - service = TextToSpeechV1(authenticator=NoAuthAuthenticator(),) + service = TextToSpeechV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.add_words(**body) return output @@ -760,17 +754,13 @@ def call_service(self, body): def construct_full_body(self): body = dict() body['customization_id'] = "string1" - body.update({ - "words": [], - }) + body.update({"words": [], }) return body def construct_required_body(self): body = dict() body['customization_id'] = "string1" - body.update({ - "words": [], - }) + body.update({"words": [], }) return body @@ -813,20 +803,21 @@ def test_list_words_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/customizations/{0}/words'.format( - body['customization_id']) + endpoint = '/v1/customizations/{0}/words'.format(body['customization_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = TextToSpeechV1(authenticator=NoAuthAuthenticator(),) + service = TextToSpeechV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.list_words(**body) return output @@ -881,20 +872,21 @@ def test_add_word_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/customizations/{0}/words/{1}'.format( - body['customization_id'], body['word']) + endpoint = '/v1/customizations/{0}/words/{1}'.format(body['customization_id'], body['word']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.PUT, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): - service = TextToSpeechV1(authenticator=NoAuthAuthenticator(),) + service = TextToSpeechV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.add_word(**body) return output @@ -903,20 +895,14 @@ def construct_full_body(self): body = dict() body['customization_id'] = "string1" body['word'] = "string1" - body.update({ - "translation": "string1", - "part_of_speech": "string1", - }) + body.update({"translation": "string1", "part_of_speech": "string1", }) return body def construct_required_body(self): body = dict() body['customization_id'] = "string1" body['word'] = "string1" - body.update({ - "translation": "string1", - "part_of_speech": "string1", - }) + body.update({"translation": "string1", "part_of_speech": "string1", }) return body @@ -959,20 +945,21 @@ def test_get_word_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/customizations/{0}/words/{1}'.format( - body['customization_id'], body['word']) + endpoint = '/v1/customizations/{0}/words/{1}'.format(body['customization_id'], body['word']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): - service = TextToSpeechV1(authenticator=NoAuthAuthenticator(),) + service = TextToSpeechV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.get_word(**body) return output @@ -1029,20 +1016,21 @@ def test_delete_word_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v1/customizations/{0}/words/{1}'.format( - body['customization_id'], body['word']) + endpoint = '/v1/customizations/{0}/words/{1}'.format(body['customization_id'], body['word']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=204, - content_type='') - + url, + body=json.dumps(response), + status=204, + content_type='') + def call_service(self, body): - service = TextToSpeechV1(authenticator=NoAuthAuthenticator(),) + service = TextToSpeechV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.delete_word(**body) return output @@ -1070,7 +1058,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for delete_user_data #----------------------------------------------------------------------------- @@ -1116,13 +1103,15 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): - service = TextToSpeechV1(authenticator=NoAuthAuthenticator(),) + service = TextToSpeechV1( + authenticator=NoAuthAuthenticator(), + ) service.set_service_url(base_url) output = service.delete_user_data(**body) return output @@ -1160,7 +1149,6 @@ def check_empty_required_params(obj, response): error = True assert error - def check_missing_required_params(obj): """Test function to assert that the operation will throw an error when missing required data @@ -1177,7 +1165,6 @@ def check_missing_required_params(obj): error = True assert error - def check_empty_response(obj): """Test function to assert that the operation will return an empty response when given an empty request @@ -1189,7 +1176,6 @@ def check_empty_response(obj): url = obj.make_url(body) send_request(obj, {}, {}, url=url) - def send_request(obj, body, response, url=None): """Test function to create a request, send it, and assert its accuracy to the mock response @@ -1206,7 +1192,6 @@ def send_request(obj, body, response, url=None): assert responses.calls[0].request.url.startswith(url) assert output.get_result() == response - #################### ## Mock Responses ## #################### diff --git a/test/unit/test_tone_analyzer_v3.py b/test/unit/test_tone_analyzer_v3.py index d9db2185d..f9e5a577e 100755 --- a/test/unit/test_tone_analyzer_v3.py +++ b/test/unit/test_tone_analyzer_v3.py @@ -28,7 +28,6 @@ ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for tone #----------------------------------------------------------------------------- @@ -74,16 +73,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = ToneAnalyzerV3( authenticator=NoAuthAuthenticator(), version='2017-09-21', - ) + ) service.set_service_url(base_url) output = service.tone(**body) return output @@ -149,34 +148,30 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = ToneAnalyzerV3( authenticator=NoAuthAuthenticator(), version='2017-09-21', - ) + ) service.set_service_url(base_url) output = service.tone_chat(**body) return output def construct_full_body(self): body = dict() - body.update({ - "utterances": [], - }) + body.update({"utterances": [], }) body['content_language'] = "string1" body['accept_language'] = "string1" return body def construct_required_body(self): body = dict() - body.update({ - "utterances": [], - }) + body.update({"utterances": [], }) return body @@ -202,7 +197,6 @@ def check_empty_required_params(obj, response): error = True assert error - def check_missing_required_params(obj): """Test function to assert that the operation will throw an error when missing required data @@ -219,7 +213,6 @@ def check_missing_required_params(obj): error = True assert error - def check_empty_response(obj): """Test function to assert that the operation will return an empty response when given an empty request @@ -231,7 +224,6 @@ def check_empty_response(obj): url = obj.make_url(body) send_request(obj, {}, {}, url=url) - def send_request(obj, body, response, url=None): """Test function to create a request, send it, and assert its accuracy to the mock response @@ -248,7 +240,6 @@ def send_request(obj, body, response, url=None): assert responses.calls[0].request.url.startswith(url) assert output.get_result() == response - #################### ## Mock Responses ## #################### diff --git a/test/unit/test_visual_recognition_v3.py b/test/unit/test_visual_recognition_v3.py index fb2b7d779..a469b83c9 100644 --- a/test/unit/test_visual_recognition_v3.py +++ b/test/unit/test_visual_recognition_v3.py @@ -30,7 +30,6 @@ ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for classify #----------------------------------------------------------------------------- @@ -75,16 +74,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = VisualRecognitionV3( authenticator=NoAuthAuthenticator(), version='2018-03-19', - ) + ) service.set_service_url(base_url) output = service.classify(**body) return output @@ -116,7 +115,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for create_classifier #----------------------------------------------------------------------------- @@ -162,16 +160,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = VisualRecognitionV3( authenticator=NoAuthAuthenticator(), version='2018-03-19', - ) + ) service.set_service_url(base_url) output = service.create_classifier(**body) return output @@ -235,16 +233,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = VisualRecognitionV3( authenticator=NoAuthAuthenticator(), version='2018-03-19', - ) + ) service.set_service_url(base_url) output = service.list_classifiers(**body) return output @@ -304,16 +302,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = VisualRecognitionV3( authenticator=NoAuthAuthenticator(), version='2018-03-19', - ) + ) service.set_service_url(base_url) output = service.get_classifier(**body) return output @@ -374,16 +372,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = VisualRecognitionV3( authenticator=NoAuthAuthenticator(), version='2018-03-19', - ) + ) service.set_service_url(base_url) output = service.update_classifier(**body) return output @@ -447,16 +445,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): service = VisualRecognitionV3( authenticator=NoAuthAuthenticator(), version='2018-03-19', - ) + ) service.set_service_url(base_url) output = service.delete_classifier(**body) return output @@ -482,7 +480,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for get_core_ml_model #----------------------------------------------------------------------------- @@ -522,23 +519,22 @@ def test_get_core_ml_model_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v3/classifiers/{0}/core_ml_model'.format( - body['classifier_id']) + endpoint = '/v3/classifiers/{0}/core_ml_model'.format(body['classifier_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): service = VisualRecognitionV3( authenticator=NoAuthAuthenticator(), version='2018-03-19', - ) + ) service.set_service_url(base_url) output = service.get_core_ml_model(**body) return output @@ -564,7 +560,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for delete_user_data #----------------------------------------------------------------------------- @@ -610,16 +605,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=202, - content_type='') - + url, + body=json.dumps(response), + status=202, + content_type='') + def call_service(self, body): service = VisualRecognitionV3( authenticator=NoAuthAuthenticator(), version='2018-03-19', - ) + ) service.set_service_url(base_url) output = service.delete_user_data(**body) return output @@ -657,7 +652,6 @@ def check_empty_required_params(obj, response): error = True assert error - def check_missing_required_params(obj): """Test function to assert that the operation will throw an error when missing required data @@ -674,7 +668,6 @@ def check_missing_required_params(obj): error = True assert error - def check_empty_response(obj): """Test function to assert that the operation will return an empty response when given an empty request @@ -686,7 +679,6 @@ def check_empty_response(obj): url = obj.make_url(body) send_request(obj, {}, {}, url=url) - def send_request(obj, body, response, url=None): """Test function to create a request, send it, and assert its accuracy to the mock response @@ -703,7 +695,6 @@ def send_request(obj, body, response, url=None): assert responses.calls[0].request.url.startswith(url) assert output.get_result() == response - #################### ## Mock Responses ## #################### diff --git a/test/unit/test_visual_recognition_v4.py b/test/unit/test_visual_recognition_v4.py index 99dc2df07..e1b9dbd56 100644 --- a/test/unit/test_visual_recognition_v4.py +++ b/test/unit/test_visual_recognition_v4.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# (C) Copyright IBM Corp. 2019, 2020. +# (C) Copyright IBM Corp. 2020. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,7 +30,6 @@ ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for analyze #----------------------------------------------------------------------------- @@ -76,16 +75,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = VisualRecognitionV4( authenticator=NoAuthAuthenticator(), version='2019-02-11', - ) + ) service.set_service_url(base_url) output = service.analyze(**body) return output @@ -116,7 +115,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for create_collection #----------------------------------------------------------------------------- @@ -161,34 +159,28 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = VisualRecognitionV4( authenticator=NoAuthAuthenticator(), version='2019-02-11', - ) + ) service.set_service_url(base_url) output = service.create_collection(**body) return output def construct_full_body(self): body = dict() - body.update({ - "name": "string1", - "description": "string1", - }) + body.update({"name": "string1", "description": "string1", }) return body def construct_required_body(self): body = dict() - body.update({ - "name": "string1", - "description": "string1", - }) + body.update({"name": "string1", "description": "string1", }) return body @@ -236,16 +228,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = VisualRecognitionV4( authenticator=NoAuthAuthenticator(), version='2019-02-11', - ) + ) service.set_service_url(base_url) output = service.list_collections(**body) return output @@ -304,16 +296,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = VisualRecognitionV4( authenticator=NoAuthAuthenticator(), version='2019-02-11', - ) + ) service.set_service_url(base_url) output = service.get_collection(**body) return output @@ -374,16 +366,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = VisualRecognitionV4( authenticator=NoAuthAuthenticator(), version='2019-02-11', - ) + ) service.set_service_url(base_url) output = service.update_collection(**body) return output @@ -391,10 +383,7 @@ def call_service(self, body): def construct_full_body(self): body = dict() body['collection_id'] = "string1" - body.update({ - "name": "string1", - "description": "string1", - }) + body.update({"name": "string1", "description": "string1", }) return body def construct_required_body(self): @@ -448,16 +437,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): service = VisualRecognitionV4( authenticator=NoAuthAuthenticator(), version='2019-02-11', - ) + ) service.set_service_url(base_url) output = service.delete_collection(**body) return output @@ -483,7 +472,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for add_images #----------------------------------------------------------------------------- @@ -529,16 +517,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = VisualRecognitionV4( authenticator=NoAuthAuthenticator(), version='2019-02-11', - ) + ) service.set_service_url(base_url) output = service.add_images(**body) return output @@ -602,16 +590,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = VisualRecognitionV4( authenticator=NoAuthAuthenticator(), version='2019-02-11', - ) + ) service.set_service_url(base_url) output = service.list_images(**body) return output @@ -666,23 +654,22 @@ def test_get_image_details_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v4/collections/{0}/images/{1}'.format( - body['collection_id'], body['image_id']) + endpoint = '/v4/collections/{0}/images/{1}'.format(body['collection_id'], body['image_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = VisualRecognitionV4( authenticator=NoAuthAuthenticator(), version='2019-02-11', - ) + ) service.set_service_url(base_url) output = service.get_image_details(**body) return output @@ -739,23 +726,22 @@ def test_delete_image_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v4/collections/{0}/images/{1}'.format( - body['collection_id'], body['image_id']) + endpoint = '/v4/collections/{0}/images/{1}'.format(body['collection_id'], body['image_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): service = VisualRecognitionV4( authenticator=NoAuthAuthenticator(), version='2019-02-11', - ) + ) service.set_service_url(base_url) output = service.delete_image(**body) return output @@ -812,23 +798,22 @@ def test_get_jpeg_image_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v4/collections/{0}/images/{1}/jpeg'.format( - body['collection_id'], body['image_id']) + endpoint = '/v4/collections/{0}/images/{1}/jpeg'.format(body['collection_id'], body['image_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): service = VisualRecognitionV4( authenticator=NoAuthAuthenticator(), version='2019-02-11', - ) + ) service.set_service_url(base_url) output = service.get_jpeg_image(**body) return output @@ -857,7 +842,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for list_object_metadata #----------------------------------------------------------------------------- @@ -903,16 +887,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = VisualRecognitionV4( authenticator=NoAuthAuthenticator(), version='2019-02-11', - ) + ) service.set_service_url(base_url) output = service.list_object_metadata(**body) return output @@ -959,8 +943,7 @@ def test_update_object_metadata_required_response(self): #-------------------------------------------------------- @responses.activate def test_update_object_metadata_empty(self): - check_empty_required_params(self, - fake_response_UpdateObjectMetadata_json) + check_empty_required_params(self, fake_response_UpdateObjectMetadata_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -968,23 +951,22 @@ def test_update_object_metadata_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v4/collections/{0}/objects/{1}'.format( - body['collection_id'], body['object']) + endpoint = '/v4/collections/{0}/objects/{1}'.format(body['collection_id'], body['object']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = VisualRecognitionV4( authenticator=NoAuthAuthenticator(), version='2019-02-11', - ) + ) service.set_service_url(base_url) output = service.update_object_metadata(**body) return output @@ -993,18 +975,14 @@ def construct_full_body(self): body = dict() body['collection_id'] = "string1" body['object'] = "string1" - body.update({ - "new_object": "string1", - }) + body.update({"new_object": "string1", }) return body def construct_required_body(self): body = dict() body['collection_id'] = "string1" body['object'] = "string1" - body.update({ - "new_object": "string1", - }) + body.update({"new_object": "string1", }) return body @@ -1047,23 +1025,22 @@ def test_get_object_metadata_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v4/collections/{0}/objects/{1}'.format( - body['collection_id'], body['object']) + endpoint = '/v4/collections/{0}/objects/{1}'.format(body['collection_id'], body['object']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = VisualRecognitionV4( authenticator=NoAuthAuthenticator(), version='2019-02-11', - ) + ) service.set_service_url(base_url) output = service.get_object_metadata(**body) return output @@ -1120,23 +1097,22 @@ def test_delete_object_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v4/collections/{0}/objects/{1}'.format( - body['collection_id'], body['object']) + endpoint = '/v4/collections/{0}/objects/{1}'.format(body['collection_id'], body['object']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=200, - content_type='') - + url, + body=json.dumps(response), + status=200, + content_type='') + def call_service(self, body): service = VisualRecognitionV4( authenticator=NoAuthAuthenticator(), version='2019-02-11', - ) + ) service.set_service_url(base_url) output = service.delete_object(**body) return output @@ -1164,7 +1140,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for train #----------------------------------------------------------------------------- @@ -1210,16 +1185,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=202, - content_type='application/json') - + url, + body=json.dumps(response), + status=202, + content_type='application/json') + def call_service(self, body): service = VisualRecognitionV4( authenticator=NoAuthAuthenticator(), version='2019-02-11', - ) + ) service.set_service_url(base_url) output = service.train(**body) return output @@ -1266,8 +1241,7 @@ def test_add_image_training_data_required_response(self): #-------------------------------------------------------- @responses.activate def test_add_image_training_data_empty(self): - check_empty_required_params(self, - fake_response_TrainingDataObjects_json) + check_empty_required_params(self, fake_response_TrainingDataObjects_json) check_missing_required_params(self) assert len(responses.calls) == 0 @@ -1275,23 +1249,22 @@ def test_add_image_training_data_empty(self): #- Helpers - #----------- def make_url(self, body): - endpoint = '/v4/collections/{0}/images/{1}/training_data'.format( - body['collection_id'], body['image_id']) + endpoint = '/v4/collections/{0}/images/{1}/training_data'.format(body['collection_id'], body['image_id']) url = '{0}{1}'.format(base_url, endpoint) return url def add_mock_response(self, url, response): responses.add(responses.POST, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = VisualRecognitionV4( authenticator=NoAuthAuthenticator(), version='2019-02-11', - ) + ) service.set_service_url(base_url) output = service.add_image_training_data(**body) return output @@ -1300,18 +1273,14 @@ def construct_full_body(self): body = dict() body['collection_id'] = "string1" body['image_id'] = "string1" - body.update({ - "objects": [], - }) + body.update({"objects": [], }) return body def construct_required_body(self): body = dict() body['collection_id'] = "string1" body['image_id'] = "string1" - body.update({ - "objects": [], - }) + body.update({"objects": [], }) return body @@ -1359,16 +1328,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.GET, - url, - body=json.dumps(response), - status=200, - content_type='application/json') - + url, + body=json.dumps(response), + status=200, + content_type='application/json') + def call_service(self, body): service = VisualRecognitionV4( authenticator=NoAuthAuthenticator(), version='2019-02-11', - ) + ) service.set_service_url(base_url) output = service.get_training_usage(**body) return output @@ -1394,7 +1363,6 @@ def construct_required_body(self): ############################################################################## # region - #----------------------------------------------------------------------------- # Test Class for delete_user_data #----------------------------------------------------------------------------- @@ -1440,16 +1408,16 @@ def make_url(self, body): def add_mock_response(self, url, response): responses.add(responses.DELETE, - url, - body=json.dumps(response), - status=202, - content_type='') - + url, + body=json.dumps(response), + status=202, + content_type='') + def call_service(self, body): service = VisualRecognitionV4( authenticator=NoAuthAuthenticator(), version='2019-02-11', - ) + ) service.set_service_url(base_url) output = service.delete_user_data(**body) return output @@ -1487,7 +1455,6 @@ def check_empty_required_params(obj, response): error = True assert error - def check_missing_required_params(obj): """Test function to assert that the operation will throw an error when missing required data @@ -1504,7 +1471,6 @@ def check_missing_required_params(obj): error = True assert error - def check_empty_response(obj): """Test function to assert that the operation will return an empty response when given an empty request @@ -1516,7 +1482,6 @@ def check_empty_response(obj): url = obj.make_url(body) send_request(obj, {}, {}, url=url) - def send_request(obj, body, response, url=None): """Test function to create a request, send it, and assert its accuracy to the mock response @@ -1533,7 +1498,6 @@ def send_request(obj, body, response, url=None): assert responses.calls[0].request.url.startswith(url) assert output.get_result() == response - #################### ## Mock Responses ## #################### From 9df996837611f80ba8581eb640423ddcef10537c Mon Sep 17 00:00:00 2001 From: Mamoon Raja Date: Thu, 16 Apr 2020 10:05:46 -0400 Subject: [PATCH 06/10] chore: update formatting and gitignore --- .gitignore | 3 +++ README.md | 4 ++-- .../assistant_tone_analyzer_integration/tone_detection.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 5d029b821..35ef69fba 100644 --- a/.gitignore +++ b/.gitignore @@ -69,3 +69,6 @@ test/__init__.py # ignore detect secrets files .pre-commit-config.yaml .secrets.baseline + +.openapi-generator-ignore +.openapi-generator/ \ No newline at end of file diff --git a/README.md b/README.md index 83c75e46e..cf620b72e 100755 --- a/README.md +++ b/README.md @@ -164,7 +164,7 @@ IBM Cloud has migrated to token-based Identity and Access Management (IAM) authe You supply either an IAM service **API key** or a **bearer token**: - Use the API key to have the SDK manage the lifecycle of the access token. The SDK requests an access token, ensures that the access token is valid, and refreshes it if necessary. -- Use the access token if you want to manage the lifecycle yourself. For details, see [Authenticating with IAM tokens](https://cloud.ibm.com/docs/services/watson?topic=watson-iam). +- Use the access token if you want to manage the lifecycle yourself. For details, see [Authenticating with IAM tokens](https://cloud.ibm.com/docs/watson?topic=watson-iam). - Use a server-side to generate access tokens using your IAM API key for untrusted environments like client-side scripts. The generated access tokens will be valid for one hour and can be refreshed. #### Supplying the API key @@ -513,5 +513,5 @@ This library is licensed under the [Apache 2.0 license][license]. [examples]: https://github.com/watson-developer-cloud/python-sdk/tree/master/examples [CONTRIBUTING]: https://github.com/watson-developer-cloud/python-sdk/blob/master/CONTRIBUTING.md [license]: http://www.apache.org/licenses/LICENSE-2.0 -[vcap_services]: https://cloud.ibm.com/docs/services/watson?topic=watson-vcapServices +[vcap_services]: https://cloud.ibm.com/docs/watson?topic=watson-vcapServices [ibm-cloud-onboarding]: https://cloud.ibm.com/registration?target=/developer/watson&cm_sp=WatsonPlatform-WatsonServices-_-OnPageNavLink-IBMWatson_SDKs-_-Python diff --git a/examples/assistant_tone_analyzer_integration/tone_detection.py b/examples/assistant_tone_analyzer_integration/tone_detection.py index dc8e36a01..d0f91fbdd 100644 --- a/examples/assistant_tone_analyzer_integration/tone_detection.py +++ b/examples/assistant_tone_analyzer_integration/tone_detection.py @@ -15,7 +15,7 @@ * Thresholds for identifying meaningful tones returned by the Watson Tone Analyzer. Current values are * based on the recommendations made by the Watson Tone Analyzer at - * https://cloud.ibm.com/docs/services/tone-analyzer?topic=tone-analyzer-utgpe + * https://cloud.ibm.com/docs/tone-analyzer?topic=tone-analyzer-utgpe * These thresholds can be adjusted to client/domain requirements. """ From a4311fb79906335742fa6d8d72ee84fc6007872c Mon Sep 17 00:00:00 2001 From: Mamoon Raja Date: Thu, 16 Apr 2020 10:14:08 -0400 Subject: [PATCH 07/10] refactor: keep cout as required param --- ibm_watson/visual_recognition_v4.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ibm_watson/visual_recognition_v4.py b/ibm_watson/visual_recognition_v4.py index 6711750cd..9f86c28d4 100644 --- a/ibm_watson/visual_recognition_v4.py +++ b/ibm_watson/visual_recognition_v4.py @@ -137,11 +137,10 @@ def analyze(self, params = {'version': self.version} form_data = [] - for item in collection_ids: - form_data.append( - ('collection_ids', (None, item, 'application/json'))) - for item in features: - form_data.append(('features', (None, item, 'application/json'))) + collection_ids = self._convert_list(collection_ids) + form_data.append(('collection_ids', (None, collection_ids, 'text/plain'))) + features = self._convert_list(features) + form_data.append(('features', (None, features, 'text/plain'))) if images_file: for item in images_file: form_data.append(('images_file', (item.filename, item.data, @@ -3144,18 +3143,18 @@ class UpdateObjectMetadata(): :attr str object: The updated name of the object. The name can contain alphanumeric, underscore, hyphen, space, and dot characters. It cannot begin with the reserved prefix `sys-`. - :attr int count: (optional) Number of bounding boxes in the collection with the + :attr int count: Number of bounding boxes in the collection with the updated object name. """ - def __init__(self, object: str, *, count: int = None) -> None: + def __init__(self, object: str, count: int) -> None: """ Initialize a UpdateObjectMetadata object. :param str object: The updated name of the object. The name can contain alphanumeric, underscore, hyphen, space, and dot characters. It cannot begin with the reserved prefix `sys-`. - :param int count: (optional) Number of bounding boxes in the collection + :param int count: Number of bounding boxes in the collection with the updated object name. """ self.object = object @@ -3179,6 +3178,10 @@ def from_dict(cls, _dict: Dict) -> 'UpdateObjectMetadata': ) if 'count' in _dict: args['count'] = _dict.get('count') + else: + raise ValueError( + 'Required property \'count\' not present in UpdateObjectMetadata JSON' + ) return cls(**args) @classmethod From 46a812c6f74a9d32a96ad566e2d25d883c24d2f7 Mon Sep 17 00:00:00 2001 From: Mamoon Raja Date: Mon, 20 Apr 2020 10:25:12 -0400 Subject: [PATCH 08/10] feat(AssistantV2): regenerate based on current API def --- ibm_watson/assistant_v2.py | 96 ++----------------------- ibm_watson/speech_to_text_v1_adapter.py | 4 +- ibm_watson/visual_recognition_v3.py | 3 +- ibm_watson/visual_recognition_v4.py | 3 +- 4 files changed, 11 insertions(+), 95 deletions(-) diff --git a/ibm_watson/assistant_v2.py b/ibm_watson/assistant_v2.py index 9f0e1fbc2..addaea126 100644 --- a/ibm_watson/assistant_v2.py +++ b/ibm_watson/assistant_v2.py @@ -1219,21 +1219,19 @@ class MessageContextSkill(): :attr dict user_defined: (optional) Arbitrary variables that can be read and written by a particular skill. - :attr MessageContextSkillSystem system: (optional) System context data used by - the skill. + :attr dict system: (optional) System context data used by the skill. """ def __init__(self, *, user_defined: dict = None, - system: 'MessageContextSkillSystem' = None) -> None: + system: dict = None) -> None: """ Initialize a MessageContextSkill object. :param dict user_defined: (optional) Arbitrary variables that can be read and written by a particular skill. - :param MessageContextSkillSystem system: (optional) System context data - used by the skill. + :param dict system: (optional) System context data used by the skill. """ self.user_defined = user_defined self.system = system @@ -1251,8 +1249,7 @@ def from_dict(cls, _dict: Dict) -> 'MessageContextSkill': if 'user_defined' in _dict: args['user_defined'] = _dict.get('user_defined') if 'system' in _dict: - args['system'] = MessageContextSkillSystem._from_dict( - _dict.get('system')) + args['system'] = _dict.get('system') return cls(**args) @classmethod @@ -1266,7 +1263,7 @@ def to_dict(self) -> Dict: if hasattr(self, 'user_defined') and self.user_defined is not None: _dict['user_defined'] = self.user_defined if hasattr(self, 'system') and self.system is not None: - _dict['system'] = self.system._to_dict() + _dict['system'] = self.system return _dict def _to_dict(self): @@ -1288,89 +1285,6 @@ def __ne__(self, other: 'MessageContextSkill') -> bool: return not self == other -class MessageContextSkillSystem(): - """ - System context data used by the skill. - - :attr str state: (optional) An encoded string representing the current - conversation state. By saving this value and then sending it in the context of a - subsequent message request, you can restore the conversation to the same state. - This can be useful if you need to return to an earlier point in the conversation - or resume a paused conversation after the session has expired. - """ - - def __init__(self, *, state: str = None, **kwargs) -> None: - """ - Initialize a MessageContextSkillSystem object. - - :param str state: (optional) An encoded string representing the current - conversation state. By saving this value and then sending it in the context - of a subsequent message request, you can restore the conversation to the - same state. This can be useful if you need to return to an earlier point in - the conversation or resume a paused conversation after the session has - expired. - :param **kwargs: (optional) Any additional properties. - """ - self.state = state - for _key, _value in kwargs.items(): - setattr(self, _key, _value) - - @classmethod - def from_dict(cls, _dict: Dict) -> 'MessageContextSkillSystem': - """Initialize a MessageContextSkillSystem object from a json dictionary.""" - args = {} - xtra = _dict.copy() - if 'state' in _dict: - args['state'] = _dict.get('state') - del xtra['state'] - args.update(xtra) - return cls(**args) - - @classmethod - def _from_dict(cls, _dict): - """Initialize a MessageContextSkillSystem 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, 'state') and self.state is not None: - _dict['state'] = self.state - if hasattr(self, '_additionalProperties'): - for _key in self._additionalProperties: - _value = getattr(self, _key, None) - if _value is not None: - _dict[_key] = _value - return _dict - - def _to_dict(self): - """Return a json dictionary representing this model.""" - return self.to_dict() - - def __setattr__(self, name: str, value: object) -> None: - properties = {'state'} - if not hasattr(self, '_additionalProperties'): - super(MessageContextSkillSystem, - self).__setattr__('_additionalProperties', set()) - if name not in properties: - self._additionalProperties.add(name) - super(MessageContextSkillSystem, self).__setattr__(name, value) - - def __str__(self) -> str: - """Return a `str` version of this MessageContextSkillSystem object.""" - return json.dumps(self._to_dict(), indent=2) - - def __eq__(self, other: 'MessageContextSkillSystem') -> 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: 'MessageContextSkillSystem') -> bool: - """Return `true` when self and other are not equal, false otherwise.""" - return not self == other - - class MessageContextSkills(): """ Information specific to particular skills used by the Assistant. diff --git a/ibm_watson/speech_to_text_v1_adapter.py b/ibm_watson/speech_to_text_v1_adapter.py index 22a565c79..11bd2d38d 100644 --- a/ibm_watson/speech_to_text_v1_adapter.py +++ b/ibm_watson/speech_to_text_v1_adapter.py @@ -53,8 +53,8 @@ def recognize_using_websocket(self, audio_metrics=None, end_of_phrase_silence_time=None, split_transcript_at_phrase_end=None, - speech_detector_sensitivity = None, - background_audio_suppression = None, + speech_detector_sensitivity=None, + background_audio_suppression=None, **kwargs): """ Sends audio for speech recognition using web sockets. diff --git a/ibm_watson/visual_recognition_v3.py b/ibm_watson/visual_recognition_v3.py index 524daef6b..efef3065a 100644 --- a/ibm_watson/visual_recognition_v3.py +++ b/ibm_watson/visual_recognition_v3.py @@ -170,7 +170,8 @@ def classify(self, form_data.append(('owners', (None, owners, 'text/plain'))) if classifier_ids: classifier_ids = self._convert_list(classifier_ids) - form_data.append(('classifier_ids', (None, classifier_ids, 'text/plain'))) + form_data.append( + ('classifier_ids', (None, classifier_ids, 'text/plain'))) url = '/v3/classify' request = self.prepare_request(method='POST', diff --git a/ibm_watson/visual_recognition_v4.py b/ibm_watson/visual_recognition_v4.py index 9f86c28d4..c7c66bdf4 100644 --- a/ibm_watson/visual_recognition_v4.py +++ b/ibm_watson/visual_recognition_v4.py @@ -138,7 +138,8 @@ def analyze(self, form_data = [] collection_ids = self._convert_list(collection_ids) - form_data.append(('collection_ids', (None, collection_ids, 'text/plain'))) + form_data.append( + ('collection_ids', (None, collection_ids, 'text/plain'))) features = self._convert_list(features) form_data.append(('features', (None, features, 'text/plain'))) if images_file: From 3a40b82f5a04af187a5243480db98b382fe954a0 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 24 Apr 2020 13:21:00 +0000 Subject: [PATCH 09/10] =?UTF-8?q?Bump=20version:=204.3.0=20=E2=86=92=204.4?= =?UTF-8?q?.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 2 +- ibm_watson/version.py | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index a12707dfe..efca55923 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 4.3.0 +current_version = 4.4.0 commit = True [bumpversion:file:ibm_watson/version.py] diff --git a/ibm_watson/version.py b/ibm_watson/version.py index 5ee6158c5..26a6c390a 100644 --- a/ibm_watson/version.py +++ b/ibm_watson/version.py @@ -1 +1 @@ -__version__ = '4.3.0' +__version__ = '4.4.0' diff --git a/setup.py b/setup.py index 7f93f020b..23bbfcc98 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ import os import sys -__version__ = '4.3.0' +__version__ = '4.4.0' if sys.argv[-1] == 'publish': From 9c81b37717249c52e3ad210433108e771aefe18c Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 24 Apr 2020 13:21:00 +0000 Subject: [PATCH 10/10] chore(release): 4.4.0 release notes # [4.4.0](https://github.com/watson-developer-cloud/python-sdk/compare/v4.3.0...v4.4.0) (2020-04-24) ### Features * **AssistantV2:** regenerate based on current API def ([46a812c](https://github.com/watson-developer-cloud/python-sdk/commit/46a812c6f74a9d32a96ad566e2d25d883c24d2f7)) * regenerate services using current API def ([e9ea20c](https://github.com/watson-developer-cloud/python-sdk/commit/e9ea20cc68a09da4e948c0622e254c31b27b481b)) * **LanguageTranslator:** add support for auto correct ([230878a](https://github.com/watson-developer-cloud/python-sdk/commit/230878a256d375c92cef0647e2f5efa51b8a5cf0)) * **SpeechToText:** add support for speech_detector_sensitivity and background_audio_suppression in ([9aa13e9](https://github.com/watson-developer-cloud/python-sdk/commit/9aa13e94558c37ca815d61ff36d0988943c55bf7)) --- CHANGELOG.md | 10 ++ package-lock.json | 267 +++++++++++++++++++++++----------------------- 2 files changed, 143 insertions(+), 134 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5dd5bb13..3db80b5cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# [4.4.0](https://github.com/watson-developer-cloud/python-sdk/compare/v4.3.0...v4.4.0) (2020-04-24) + + +### Features + +* **AssistantV2:** regenerate based on current API def ([46a812c](https://github.com/watson-developer-cloud/python-sdk/commit/46a812c6f74a9d32a96ad566e2d25d883c24d2f7)) +* regenerate services using current API def ([e9ea20c](https://github.com/watson-developer-cloud/python-sdk/commit/e9ea20cc68a09da4e948c0622e254c31b27b481b)) +* **LanguageTranslator:** add support for auto correct ([230878a](https://github.com/watson-developer-cloud/python-sdk/commit/230878a256d375c92cef0647e2f5efa51b8a5cf0)) +* **SpeechToText:** add support for speech_detector_sensitivity and background_audio_suppression in ([9aa13e9](https://github.com/watson-developer-cloud/python-sdk/commit/9aa13e94558c37ca815d61ff36d0988943c55bf7)) + # [4.3.0](https://github.com/watson-developer-cloud/python-sdk/compare/v4.2.1...v4.3.0) (2020-02-13) diff --git a/package-lock.json b/package-lock.json index ee51a62e1..c151f747d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,13 +10,18 @@ "@babel/highlight": "^7.8.3" } }, + "@babel/helper-validator-identifier": { + "version": "7.9.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.5.tgz", + "integrity": "sha512-/8arLKUFq882w4tWGj9JYzRpAlZgiWUJ+dtteNTDqrRBz9Iguck9Rn3ykuBDoUwh2TO4tSAJlrxDUOXWklJe4g==" + }, "@babel/highlight": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.8.3.tgz", - "integrity": "sha512-PX4y5xQUvy0fnEVHrYOarRPXVWafSjTW9T0Hab8gVIawpl2Sj0ORyrygANq+KjcNlSSTw0YCLSNA8OyZ1I4yEg==", + "version": "7.9.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.9.0.tgz", + "integrity": "sha512-lJZPilxX7Op3Nv/2cvFdnlepPXDxi29wxteT57Q965oc5R9v86ztx0jfxVrTcBk8C2kcPkkDa2Z4T3ZsPPVWsQ==", "requires": { + "@babel/helper-validator-identifier": "^7.9.0", "chalk": "^2.0.0", - "esutils": "^2.0.2", "js-tokens": "^4.0.0" } }, @@ -51,22 +56,55 @@ "@octokit/types": "^2.0.0" } }, - "@octokit/endpoint": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-5.5.2.tgz", - "integrity": "sha512-ICDcRA0C2vtTZZGud1nXRrBLXZqFayodXAKZfo3dkdcLNqcHsgaz3YSTupbURusYeucSVRjjG+RTcQhx6HPPcg==", + "@octokit/core": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@octokit/core/-/core-2.5.0.tgz", + "integrity": "sha512-uvzmkemQrBgD8xuGbjhxzJN1darJk9L2cS+M99cHrDG2jlSVpxNJVhoV86cXdYBqdHCc9Z995uLCczaaHIYA6Q==", "requires": { + "@octokit/auth-token": "^2.4.0", + "@octokit/graphql": "^4.3.1", + "@octokit/request": "^5.4.0", "@octokit/types": "^2.0.0", + "before-after-hook": "^2.1.0", + "universal-user-agent": "^5.0.0" + } + }, + "@octokit/endpoint": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.1.tgz", + "integrity": "sha512-pOPHaSz57SFT/m3R5P8MUu4wLPszokn5pXcB/pzavLTQf2jbU+6iayTvzaY6/BiotuRS0qyEUkx3QglT4U958A==", + "requires": { + "@octokit/types": "^2.11.1", "is-plain-object": "^3.0.0", + "universal-user-agent": "^5.0.0" + } + }, + "@octokit/graphql": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.3.1.tgz", + "integrity": "sha512-hCdTjfvrK+ilU2keAdqNBWOk+gm1kai1ZcdjRfB30oA3/T6n53UVJb7w0L5cR3/rhU91xT3HSqCd+qbvH06yxA==", + "requires": { + "@octokit/request": "^5.3.0", + "@octokit/types": "^2.0.0", "universal-user-agent": "^4.0.0" + }, + "dependencies": { + "universal-user-agent": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-4.0.1.tgz", + "integrity": "sha512-LnST3ebHwVL2aNe4mejI9IQh2HfZ1RLo8Io2HugSif8ekzD1TlWpHpColOB/eh8JHMLkGH3Akqf040I+4ylNxg==", + "requires": { + "os-name": "^3.1.0" + } + } } }, "@octokit/plugin-paginate-rest": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-1.1.2.tgz", - "integrity": "sha512-jbsSoi5Q1pj63sC16XIUboklNw+8tL9VOnJsWycWYR78TKss5PVpIPb1TUUcMQ+bBh7cY579cVAWmf5qG+dw+Q==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.2.0.tgz", + "integrity": "sha512-KoNxC3PLNar8UJwR+1VMQOw2IoOrrFdo5YOiDKnBhpVbKpw+zkBKNMNKwM44UWL25Vkn0Sl3nYIEGKY+gW5ebw==", "requires": { - "@octokit/types": "^2.0.1" + "@octokit/types": "^2.12.1" } }, "@octokit/plugin-request-log": { @@ -75,33 +113,33 @@ "integrity": "sha512-ywoxP68aOT3zHCLgWZgwUJatiENeHE7xJzYjfz8WI0goynp96wETBF+d95b8g/uL4QmS6owPVlaxiz3wyMAzcw==" }, "@octokit/plugin-rest-endpoint-methods": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-2.4.0.tgz", - "integrity": "sha512-EZi/AWhtkdfAYi01obpX0DF7U6b1VRr30QNQ5xSFPITMdLSfhcBqjamE3F+sKcxPbD7eZuMHu3Qkk2V+JGxBDQ==", + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-3.8.0.tgz", + "integrity": "sha512-LUkTgZ53adPFC/Hw6mxvAtShUtGy3zbpcfCAJMWAN7SvsStV4p6TK7TocSv0Aak4TNmDLhbShTagGhpgz9mhYw==", "requires": { - "@octokit/types": "^2.0.1", + "@octokit/types": "^2.12.1", "deprecation": "^2.3.1" } }, "@octokit/request": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.3.1.tgz", - "integrity": "sha512-5/X0AL1ZgoU32fAepTfEoggFinO3rxsMLtzhlUX+RctLrusn/CApJuGFCd0v7GMFhF+8UiCsTTfsu7Fh1HnEJg==", + "version": "5.4.2", + "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.4.2.tgz", + "integrity": "sha512-zKdnGuQ2TQ2vFk9VU8awFT4+EYf92Z/v3OlzRaSh4RIP0H6cvW1BFPXq4XYvNez+TPQjqN+0uSkCYnMFFhcFrw==", "requires": { - "@octokit/endpoint": "^5.5.0", - "@octokit/request-error": "^1.0.1", - "@octokit/types": "^2.0.0", + "@octokit/endpoint": "^6.0.1", + "@octokit/request-error": "^2.0.0", + "@octokit/types": "^2.11.1", "deprecation": "^2.0.0", "is-plain-object": "^3.0.0", "node-fetch": "^2.3.0", "once": "^1.4.0", - "universal-user-agent": "^4.0.0" + "universal-user-agent": "^5.0.0" } }, "@octokit/request-error": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-1.2.1.tgz", - "integrity": "sha512-+6yDyk1EES6WK+l3viRDElw96MvwfJxCt45GvmjDUKWjYIb3PJZQkq3i46TwGwoPD4h8NmTrENmtyA1FwbmhRA==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.0.0.tgz", + "integrity": "sha512-rtYicB4Absc60rUv74Rjpzek84UbVHGHJRu4fNVlZ1mCcyUPPuzFfG9Rn6sjHrd95DEsmjSt1Axlc699ZlbDkw==", "requires": { "@octokit/types": "^2.0.0", "deprecation": "^2.0.0", @@ -109,44 +147,32 @@ } }, "@octokit/rest": { - "version": "16.43.1", - "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-16.43.1.tgz", - "integrity": "sha512-gfFKwRT/wFxq5qlNjnW2dh+qh74XgTQ2B179UX5K1HYCluioWj8Ndbgqw2PVqa1NnVJkGHp2ovMpVn/DImlmkw==", + "version": "17.6.0", + "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-17.6.0.tgz", + "integrity": "sha512-knh+4hPBA26AMXflFRupTPT3u9NcQmQzeBJl4Gcuf14Gn7dUh6Loc1ICWF0Pz18A6ElFZQt+wB9tFINSruIa+g==", "requires": { - "@octokit/auth-token": "^2.4.0", - "@octokit/plugin-paginate-rest": "^1.1.1", + "@octokit/core": "^2.4.3", + "@octokit/plugin-paginate-rest": "^2.2.0", "@octokit/plugin-request-log": "^1.0.0", - "@octokit/plugin-rest-endpoint-methods": "2.4.0", - "@octokit/request": "^5.2.0", - "@octokit/request-error": "^1.0.2", - "atob-lite": "^2.0.0", - "before-after-hook": "^2.0.0", - "btoa-lite": "^1.0.0", - "deprecation": "^2.0.0", - "lodash.get": "^4.4.2", - "lodash.set": "^4.3.2", - "lodash.uniq": "^4.5.0", - "octokit-pagination-methods": "^1.1.0", - "once": "^1.4.0", - "universal-user-agent": "^4.0.0" + "@octokit/plugin-rest-endpoint-methods": "3.8.0" } }, "@octokit/types": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@octokit/types/-/types-2.1.1.tgz", - "integrity": "sha512-89LOYH+d/vsbDX785NOfLxTW88GjNd0lWRz1DVPVsZgg9Yett5O+3MOvwo7iHgvUwbFz0mf/yPIjBkUbs4kxoQ==", + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-2.12.1.tgz", + "integrity": "sha512-LRLR1tjbcCfAmUElvTmMvLEzstpx6Xt/aQVTg2xvd+kHA2Ekp1eWl5t+gU7bcwjXHYEAzh4hH4WH+kS3vh+wRw==", "requires": { "@types/node": ">= 8" } }, "@semantic-release/changelog": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@semantic-release/changelog/-/changelog-5.0.0.tgz", - "integrity": "sha512-A1uKqWtQG4WX9Vh4QI5b2ddhqx1qAJFlbow8szSNiXn+TaJg15LSUA9NVqyu0VxQFy3hKUJYwbBHGRXCxCy2fg==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@semantic-release/changelog/-/changelog-5.0.1.tgz", + "integrity": "sha512-unvqHo5jk4dvAf2nZ3aw4imrlwQ2I50eVVvq9D47Qc3R+keNqepx1vDYwkjF8guFXnOYaYcR28yrZWno1hFbiw==", "requires": { "@semantic-release/error": "^2.1.0", "aggregate-error": "^3.0.0", - "fs-extra": "^8.0.0", + "fs-extra": "^9.0.0", "lodash": "^4.17.4" } }, @@ -184,17 +210,17 @@ } }, "@semantic-release/github": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/@semantic-release/github/-/github-7.0.3.tgz", - "integrity": "sha512-4Y2nqruKHsdoayq/H/lMWudONXHLbYtSBDZPktoTrvdJZNQkLhjnxCwDUTKo8G29aI81RuoYKUHv6GSgyJDtGQ==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/@semantic-release/github/-/github-7.0.5.tgz", + "integrity": "sha512-1nJCMeomspRIXKiFO3VXtkUMbIBEreYLFNBdWoLjvlUNcEK0/pEbupEZJA3XHfJuSzv43u3OLpPhF/JBrMuv+A==", "requires": { - "@octokit/rest": "^16.43.0", + "@octokit/rest": "^17.0.0", "@semantic-release/error": "^2.2.0", "aggregate-error": "^3.0.0", "bottleneck": "^2.18.1", "debug": "^4.0.0", "dir-glob": "^3.0.0", - "fs-extra": "^8.0.0", + "fs-extra": "^9.0.0", "globby": "^11.0.0", "http-proxy-agent": "^4.0.0", "https-proxy-agent": "^5.0.0", @@ -207,14 +233,14 @@ } }, "@tootallnate/once": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.0.0.tgz", - "integrity": "sha512-KYyTT/T6ALPkIRd2Ge080X/BsXvy9O0hcWTtMWkPvwAwF99+vn6Dv4GzrFT/Nn1LePr+FFDbRXXlqmsy9lw2zA==" + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", + "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==" }, "@types/node": { - "version": "13.7.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-13.7.1.tgz", - "integrity": "sha512-Zq8gcQGmn4txQEJeiXo/KiLpon8TzAl0kmKH4zdWctPj05nWwp1ClMdAVEloqrQKfaC48PNLdgN/aVaLqUrluA==" + "version": "13.13.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.2.tgz", + "integrity": "sha512-LB2R1Oyhpg8gu4SON/mfforE525+Hi/M1ineICEDftqNVTyFg1aRIeGuTvXAoWHc4nbrFncWtJgMmoyRvuGh7A==" }, "@types/retry": { "version": "0.12.0", @@ -251,10 +277,10 @@ "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==" }, - "atob-lite": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/atob-lite/-/atob-lite-2.0.0.tgz", - "integrity": "sha1-D+9a1G8b16hQLGVyfwNn1e5D1pY=" + "at-least-node": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", + "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==" }, "before-after-hook": { "version": "2.1.0", @@ -274,11 +300,6 @@ "fill-range": "^7.0.1" } }, - "btoa-lite": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/btoa-lite/-/btoa-lite-1.0.0.tgz", - "integrity": "sha1-M3dm2hWAEhD92VbCLpxokaudAzc=" - }, "chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", @@ -308,9 +329,9 @@ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" }, "cross-spawn": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.1.tgz", - "integrity": "sha512-u7v4o84SwFpD32Z8IIcPZ6z1/ie24O6RU3RbtL5Y316l3KuHVPx9ItBgWQ6VlfAFnRnTtMUrsQ9MUUTuEZjogg==", + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.2.tgz", + "integrity": "sha512-PD6G8QG3S4FK/XCGFbEQrDqO2AnMMsy0meR7lerlIOHAAbkuavGU/pOqprrlvfTNjvowivTeBsjebAL0NSoMxw==", "requires": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -359,11 +380,6 @@ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" }, - "esutils": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" - }, "execa": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/execa/-/execa-4.0.0.tgz", @@ -381,23 +397,24 @@ } }, "fast-glob": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.1.1.tgz", - "integrity": "sha512-nTCREpBY8w8r+boyFYAx21iL6faSsQynliPHM4Uf56SbkyohCNxpVPEH9xrF5TXKy+IsjkPUHDKiUkzBVRXn9g==", + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.2.tgz", + "integrity": "sha512-UDV82o4uQyljznxwMxyVRJgZZt3O5wENYojjzbaGEGZgeOxkLFf+V4cnUD+krzb2F72E18RhamkMZ7AdeggF7A==", "requires": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", "glob-parent": "^5.1.0", "merge2": "^1.3.0", - "micromatch": "^4.0.2" + "micromatch": "^4.0.2", + "picomatch": "^2.2.1" } }, "fastq": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.6.0.tgz", - "integrity": "sha512-jmxqQ3Z/nXoeyDmWAzF9kH1aGZSis6e/SbfPmJpUnyZ0ogr6iscHQaml4wsEepEWSdtmpy+eVXmCRIMpxaXqOA==", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.7.0.tgz", + "integrity": "sha512-YOadQRnHd5q6PogvAR/x62BGituF2ufiEA6s8aavQANw5YKHERI4AREboX6KotzP8oX2klxYF2wcV/7bn1clfQ==", "requires": { - "reusify": "^1.0.0" + "reusify": "^1.0.4" } }, "fill-range": { @@ -409,13 +426,14 @@ } }, "fs-extra": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", - "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.0.0.tgz", + "integrity": "sha512-pmEYSk3vYsG/bF651KPUXZ+hvjpgWYw/Gc7W9NFUe3ZVLczKKWIij3IKpOrQcdw4TILtibFslZ0UmR8Vvzig4g==", "requires": { + "at-least-node": "^1.0.0", "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" + "jsonfile": "^6.0.1", + "universalify": "^1.0.0" } }, "get-stream": { @@ -427,9 +445,9 @@ } }, "glob-parent": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz", - "integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", + "integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==", "requires": { "is-glob": "^4.0.1" } @@ -560,11 +578,12 @@ "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==" }, "jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.0.1.tgz", + "integrity": "sha512-jR2b5v7d2vIOust+w3wtFKZIfpC2pnRmFAhAC/BuweZFQR8qZzxH1OyrQ10HmdVYiXWkYUqPVsz91cG7EL2FBg==", "requires": { - "graceful-fs": "^4.1.6" + "graceful-fs": "^4.1.6", + "universalify": "^1.0.0" } }, "lines-and-columns": { @@ -587,11 +606,6 @@ "resolved": "https://registry.npmjs.org/lodash.escaperegexp/-/lodash.escaperegexp-4.1.2.tgz", "integrity": "sha1-ZHYsSGGAglGKw99Mz11YhtriA0c=" }, - "lodash.get": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", - "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=" - }, "lodash.isplainobject": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", @@ -602,16 +616,6 @@ "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", "integrity": "sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=" }, - "lodash.set": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/lodash.set/-/lodash.set-4.3.2.tgz", - "integrity": "sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM=" - }, - "lodash.uniq": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz", - "integrity": "sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=" - }, "lodash.uniqby": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/lodash.uniqby/-/lodash.uniqby-4.7.0.tgz", @@ -674,11 +678,6 @@ "path-key": "^3.0.0" } }, - "octokit-pagination-methods": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/octokit-pagination-methods/-/octokit-pagination-methods-1.1.0.tgz", - "integrity": "sha512-fZ4qZdQ2nxJvtcasX7Ghl+WlWS/d9IgnBIwFZXVNNZUmzpno91SX5bc5vuxiuKoCtK78XxGGNuSCrDC7xYB3OQ==" - }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -758,9 +757,9 @@ "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==" }, "picomatch": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.1.tgz", - "integrity": "sha512-ISBaA8xQNmwELC7eOjqFKMESB2VIqt4PPDD0nsS95b/9dZXvVKOlz9keMSnoGGKcOHXfTvDD6WMaRoSc9UuhRA==" + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", + "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==" }, "pump": { "version": "3.0.0", @@ -805,9 +804,9 @@ "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==" }, "signal-exit": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", + "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==" }, "slash": { "version": "3.0.0", @@ -841,17 +840,17 @@ } }, "universal-user-agent": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-4.0.0.tgz", - "integrity": "sha512-eM8knLpev67iBDizr/YtqkJsF3GK8gzDc6st/WKzrTuPtcsOKW/0IdL4cnMBsU69pOx0otavLWBDGTwg+dB0aA==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-5.0.0.tgz", + "integrity": "sha512-B5TPtzZleXyPrUMKCpEHFmVhMN6EhmJYjG5PQna9s7mXeSqGTLap4OpqLl5FCEFUI3UBmllkETwKf/db66Y54Q==", "requires": { "os-name": "^3.1.0" } }, "universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-1.0.0.tgz", + "integrity": "sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug==" }, "url-join": { "version": "4.0.1", @@ -867,9 +866,9 @@ } }, "windows-release": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/windows-release/-/windows-release-3.2.0.tgz", - "integrity": "sha512-QTlz2hKLrdqukrsapKsINzqMgOUpQW268eJ0OaOpJN32h272waxR9fkB9VoWRtK7uKHG5EHJcTXQBD8XZVJkFA==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/windows-release/-/windows-release-3.3.0.tgz", + "integrity": "sha512-2HetyTg1Y+R+rUgrKeUEhAG/ZuOmTrI1NBb3ZyAGQMYmOJjBBPe4MTodghRkmLJZHwkuPi02anbeGP+Zf401LQ==", "requires": { "execa": "^1.0.0" },