Python google.api_core.exceptions.InvalidArgument() Examples
The following are 6
code examples of google.api_core.exceptions.InvalidArgument().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
google.api_core.exceptions
, or try the search function
.
Example #1
Source File: test_system.py From python-firestore with Apache License 2.0 | 5 votes |
def test_cannot_use_foreign_key(client, cleanup): document_id = "cannot" + UNIQUE_RESOURCE_ID document = client.document("foreign-key", document_id) # Add to clean-up before API request (in case ``create()`` fails). cleanup(document.delete) other_client = firestore.Client( project="other-prahj", credentials=client._credentials, database="dee-bee" ) assert other_client._database_string != client._database_string fake_doc = other_client.document("foo", "bar") with pytest.raises(InvalidArgument): document.create({"ref": fake_doc})
Example #2
Source File: samples_test.py From python-docs-samples with Apache License 2.0 | 5 votes |
def test_delete_note(self): samples.delete_note(self.note_id, PROJECT_ID) try: samples.get_note(self.note_obj, PROJECT_ID) except InvalidArgument: pass else: # didn't raise exception we expected assert (False)
Example #3
Source File: quickstart_batchgetassetshistory_test.py From python-docs-samples with Apache License 2.0 | 5 votes |
def test_batch_get_assets_history(asset_bucket, capsys): bucket_asset_name = '//storage.googleapis.com/{}'.format(BUCKET) asset_names = [bucket_asset_name, ] @backoff.on_exception( backoff.expo, (AssertionError, InvalidArgument), max_time=30 ) def eventually_consistent_test(): quickstart_batchgetassetshistory.batch_get_assets_history( PROJECT, asset_names) out, _ = capsys.readouterr() assert bucket_asset_name in out eventually_consistent_test()
Example #4
Source File: test_grpc_unary.py From gapic-generator-python with Apache License 2.0 | 5 votes |
def test_unary_error(echo): message = 'Bad things! Bad things!' with pytest.raises(exceptions.InvalidArgument) as exc: echo.echo({ 'error': { 'code': code_pb2.Code.Value('INVALID_ARGUMENT'), 'message': message, }, }) assert exc.value.code == 400 assert exc.value.message == message
Example #5
Source File: test_grpc_unary.py From gapic-generator-python with Apache License 2.0 | 5 votes |
def test_async_unary_error(async_echo): message = 'Bad things! Bad things!' with pytest.raises(exceptions.InvalidArgument) as exc: await async_echo.echo({ 'error': { 'code': code_pb2.Code.Value('INVALID_ARGUMENT'), 'message': message, }, }) assert exc.value.code == 400 assert exc.value.message == message
Example #6
Source File: google_client.py From dialogflow_ros with MIT License | 4 votes |
def _listen_print_loop(self, responses): """Iterates through server responses and prints them. The responses passed is a generator that will block until a response is provided by the server. Each response may contain multiple results, and each result may contain multiple alternatives; for details, see https://goo.gl/tjCPAU. Here we print only the transcription for the top alternative of the top result. """ try: for response in responses: # If not a valid response, move on to next potential one if not response.results: continue # The `results` list is consecutive. For streaming, we only care about # the first result being considered, since once it's `is_final`, it # moves on to considering the next utterance. result = response.results[0] if not result.alternatives: continue # Display the transcription of the top alternative. transcript = result.alternatives[0].transcript # Parse the final utterance if result.is_final: rospy.logdebug("Google Speech result: {}".format(transcript)) # Received data is Unicode, convert it to string transcript = transcript.encode('utf-8') # Strip the initial space if any if transcript.startswith(' '): transcript = transcript[1:] # Exit if needed if transcript.lower() == 'exit' or rospy.is_shutdown(): self.shutdown() # Send the rest of the sentence to topic self.text_pub.publish(result[1]) except InvalidArgument as e: rospy.logwarn("{} caught in Mic. Client".format(e)) self.gspeech_client() except OutOfRange as e: rospy.logwarn("{} caught in Mic. Client".format(e)) self.gspeech_client()