From d8d5f5905e4b5135dee0c8e8a67db5b1fa334811 Mon Sep 17 00:00:00 2001 From: kbalk <7536198+kbalk@users.noreply.github.com> Date: Tue, 15 Aug 2023 04:04:33 -0400 Subject: [PATCH] Techdebt: Replace sure with regular assertions in Transcribe (#6664) --- .../test_transcribe/test_transcribe_boto3.py | 712 +++++++++--------- 1 file changed, 354 insertions(+), 358 deletions(-) diff --git a/tests/test_transcribe/test_transcribe_boto3.py b/tests/test_transcribe/test_transcribe_boto3.py index d64af5462..a39d8156d 100644 --- a/tests/test_transcribe/test_transcribe_boto3.py +++ b/tests/test_transcribe/test_transcribe_boto3.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- import boto3 -import sure # noqa # pylint: disable=unused-import +import pytest from moto import mock_transcribe @@ -21,55 +21,56 @@ def test_run_medical_transcription_job_minimal_params(): "Type": "CONVERSATION", } resp = client.start_medical_transcription_job(**args) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 # CREATED resp = client.get_medical_transcription_job(MedicalTranscriptionJobName=job_name) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 transcription_job = resp["MedicalTranscriptionJob"] - transcription_job["MedicalTranscriptionJobName"].should.equal( + assert transcription_job["MedicalTranscriptionJobName"] == ( args["MedicalTranscriptionJobName"] ) - transcription_job["TranscriptionJobStatus"].should.equal("QUEUED") - transcription_job["LanguageCode"].should.equal(args["LanguageCode"]) - transcription_job["Media"].should.equal(args["Media"]) - transcription_job.should.contain("CreationTime") - transcription_job.doesnt.contain("StartTime") - transcription_job.doesnt.contain("CompletionTime") - transcription_job.doesnt.contain("Transcript") - transcription_job["Settings"]["ChannelIdentification"].should.equal(False) - transcription_job["Settings"]["ShowAlternatives"].should.equal(False) - transcription_job["Specialty"].should.equal(args["Specialty"]) - transcription_job["Type"].should.equal(args["Type"]) + assert transcription_job["TranscriptionJobStatus"] == "QUEUED" + assert transcription_job["LanguageCode"] == args["LanguageCode"] + assert transcription_job["Media"] == args["Media"] + assert "CreationTime" in transcription_job + assert "StartTime" not in transcription_job + assert "CompletionTime" not in transcription_job + assert "Transcript" not in transcription_job + assert transcription_job["Settings"]["ChannelIdentification"] is False + assert transcription_job["Settings"]["ShowAlternatives"] is False + assert transcription_job["Specialty"] == args["Specialty"] + assert transcription_job["Type"] == args["Type"] # IN_PROGRESS resp = client.get_medical_transcription_job(MedicalTranscriptionJobName=job_name) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 transcription_job = resp["MedicalTranscriptionJob"] - transcription_job["TranscriptionJobStatus"].should.equal("IN_PROGRESS") - transcription_job["MediaFormat"].should.equal("wav") - transcription_job.should.contain("StartTime") - transcription_job.doesnt.contain("CompletionTime") - transcription_job.doesnt.contain("Transcript") - transcription_job["MediaSampleRateHertz"].should.equal(44100) + assert transcription_job["TranscriptionJobStatus"] == "IN_PROGRESS" + assert transcription_job["MediaFormat"] == "wav" + assert "StartTime" in transcription_job + assert "CompletionTime" not in transcription_job + assert "Transcript" not in transcription_job + assert transcription_job["MediaSampleRateHertz"] == 44100 # COMPLETED resp = client.get_medical_transcription_job(MedicalTranscriptionJobName=job_name) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 transcription_job = resp["MedicalTranscriptionJob"] - transcription_job["TranscriptionJobStatus"].should.equal("COMPLETED") - transcription_job.should.contain("CompletionTime") - transcription_job["Transcript"].should.equal( - { - "TranscriptFileUri": f"https://s3.{region_name}.amazonaws.com/{args['OutputBucketName']}/medical/{args['MedicalTranscriptionJobName']}.json" - } - ) + assert transcription_job["TranscriptionJobStatus"] == "COMPLETED" + assert "CompletionTime" in transcription_job + assert transcription_job["Transcript"] == { + "TranscriptFileUri": ( + f"https://s3.{region_name}.amazonaws.com" + f"/{args['OutputBucketName']}/medical" + f"/{args['MedicalTranscriptionJobName']}.json" + ), + } # Delete client.delete_medical_transcription_job(MedicalTranscriptionJobName=job_name) - client.get_medical_transcription_job.when.called_with( - MedicalTranscriptionJobName=job_name - ).should.throw(client.exceptions.BadRequestException) + with pytest.raises(client.exceptions.BadRequestException): + client.get_medical_transcription_job(MedicalTranscriptionJobName=job_name) @mock_transcribe @@ -84,7 +85,7 @@ def test_run_medical_transcription_job_all_params(): LanguageCode="en-US", VocabularyFileUri="https://s3.us-east-1.amazonaws.com/AWSDOC-EXAMPLE-BUCKET/vocab.txt", ) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 job_name = "MyJob2" args = { @@ -94,7 +95,10 @@ def test_run_medical_transcription_job_all_params(): "MediaFormat": "flac", "Media": {"MediaFileUri": "s3://my-bucket/my-media-file.dat"}, "OutputBucketName": "my-output-bucket", - "OutputEncryptionKMSKeyId": "arn:aws:kms:us-east-1:012345678901:key/37111b5e-8eff-4706-ae3a-d4f9d1d559fc", + "OutputEncryptionKMSKeyId": ( + "arn:aws:kms:us-east-1:012345678901:key" + "/37111b5e-8eff-4706-ae3a-d4f9d1d559fc" + ), "Settings": { "ShowSpeakerLabels": True, "MaxSpeakerLabels": 5, @@ -107,66 +111,68 @@ def test_run_medical_transcription_job_all_params(): "Type": "CONVERSATION", } resp = client.start_medical_transcription_job(**args) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 # CREATED resp = client.get_medical_transcription_job(MedicalTranscriptionJobName=job_name) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 transcription_job = resp["MedicalTranscriptionJob"] - transcription_job["MedicalTranscriptionJobName"].should.equal( + assert transcription_job["MedicalTranscriptionJobName"] == ( args["MedicalTranscriptionJobName"] ) - transcription_job["TranscriptionJobStatus"].should.equal("QUEUED") - transcription_job["LanguageCode"].should.equal(args["LanguageCode"]) - transcription_job["Media"].should.equal(args["Media"]) - transcription_job.should.contain("CreationTime") - transcription_job.doesnt.contain("StartTime") - transcription_job.doesnt.contain("CompletionTime") - transcription_job.doesnt.contain("Transcript") - transcription_job["Settings"]["ShowSpeakerLabels"].should.equal( + assert transcription_job["TranscriptionJobStatus"] == "QUEUED" + assert transcription_job["LanguageCode"] == args["LanguageCode"] + assert transcription_job["Media"] == args["Media"] + assert "CreationTime" in transcription_job + assert "StartTime" not in transcription_job + assert "CompletionTime" not in transcription_job + assert "Transcript" not in transcription_job + assert transcription_job["Settings"]["ShowSpeakerLabels"] == ( args["Settings"]["ShowSpeakerLabels"] ) - transcription_job["Settings"]["MaxSpeakerLabels"].should.equal( + assert transcription_job["Settings"]["MaxSpeakerLabels"] == ( args["Settings"]["MaxSpeakerLabels"] ) - transcription_job["Settings"]["ChannelIdentification"].should.equal( + assert transcription_job["Settings"]["ChannelIdentification"] == ( args["Settings"]["ChannelIdentification"] ) - transcription_job["Settings"]["ShowAlternatives"].should.equal( + assert transcription_job["Settings"]["ShowAlternatives"] == ( args["Settings"]["ShowAlternatives"] ) - transcription_job["Settings"]["MaxAlternatives"].should.equal( + assert transcription_job["Settings"]["MaxAlternatives"] == ( args["Settings"]["MaxAlternatives"] ) - transcription_job["Settings"]["VocabularyName"].should.equal( + assert transcription_job["Settings"]["VocabularyName"] == ( args["Settings"]["VocabularyName"] ) - transcription_job["Specialty"].should.equal(args["Specialty"]) - transcription_job["Type"].should.equal(args["Type"]) + assert transcription_job["Specialty"] == args["Specialty"] + assert transcription_job["Type"] == args["Type"] # IN_PROGRESS resp = client.get_medical_transcription_job(MedicalTranscriptionJobName=job_name) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 transcription_job = resp["MedicalTranscriptionJob"] - transcription_job["TranscriptionJobStatus"].should.equal("IN_PROGRESS") - transcription_job["MediaFormat"].should.equal("flac") - transcription_job.should.contain("StartTime") - transcription_job.doesnt.contain("CompletionTime") - transcription_job.doesnt.contain("Transcript") - transcription_job["MediaSampleRateHertz"].should.equal(48000) + assert transcription_job["TranscriptionJobStatus"] == "IN_PROGRESS" + assert transcription_job["MediaFormat"] == "flac" + assert "StartTime" in transcription_job + assert "CompletionTime" not in transcription_job + assert "Transcript" not in transcription_job + assert transcription_job["MediaSampleRateHertz"] == 48000 # COMPLETED resp = client.get_medical_transcription_job(MedicalTranscriptionJobName=job_name) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 transcription_job = resp["MedicalTranscriptionJob"] - transcription_job["TranscriptionJobStatus"].should.equal("COMPLETED") - transcription_job.should.contain("CompletionTime") - transcription_job["Transcript"].should.equal( - { - "TranscriptFileUri": f"https://s3.{region_name}.amazonaws.com/{args['OutputBucketName']}/medical/{args['MedicalTranscriptionJobName']}.json" - } - ) + assert transcription_job["TranscriptionJobStatus"] == "COMPLETED" + assert "CompletionTime" in transcription_job + assert transcription_job["Transcript"] == { + "TranscriptFileUri": ( + f"https://s3.{region_name}.amazonaws.com" + f"/{args['OutputBucketName']}/medical" + f"/{args['MedicalTranscriptionJobName']}.json" + ), + } @mock_transcribe @@ -181,7 +187,7 @@ def test_run_transcription_job_all_params(): LanguageCode="en-US", VocabularyFileUri="https://s3.us-east-1.amazonaws.com/AWSDOC-EXAMPLE-BUCKET/vocab.txt", ) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 job_name = "MyJob2" args = { @@ -191,7 +197,10 @@ def test_run_transcription_job_all_params(): "MediaFormat": "flac", "Media": {"MediaFileUri": "s3://my-bucket/my-media-file.dat"}, "OutputBucketName": "my-output-bucket", - "OutputEncryptionKMSKeyId": "arn:aws:kms:us-east-1:012345678901:key/37111b5e-8eff-4706-ae3a-d4f9d1d559fc", + "OutputEncryptionKMSKeyId": ( + "arn:aws:kms:us-east-1:012345678901:key" + "/37111b5e-8eff-4706-ae3a-d4f9d1d559fc" + ), "Settings": { "ShowSpeakerLabels": True, "MaxSpeakerLabels": 5, @@ -200,63 +209,66 @@ def test_run_transcription_job_all_params(): "MaxAlternatives": 6, "VocabularyName": vocabulary_name, }, - # Missing `ContentRedaction`, `JobExecutionSettings`, `VocabularyFilterName`, `LanguageModel` + # Missing `ContentRedaction`, `JobExecutionSettings`, + # `VocabularyFilterName`, `LanguageModel` } resp = client.start_transcription_job(**args) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 # CREATED resp = client.get_transcription_job(TranscriptionJobName=job_name) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 transcription_job = resp["TranscriptionJob"] - transcription_job["TranscriptionJobName"].should.equal(args["TranscriptionJobName"]) - transcription_job["TranscriptionJobStatus"].should.equal("QUEUED") - transcription_job["LanguageCode"].should.equal(args["LanguageCode"]) - transcription_job["Media"].should.equal(args["Media"]) - transcription_job.should.contain("CreationTime") - transcription_job.doesnt.contain("StartTime") - transcription_job.doesnt.contain("CompletionTime") - transcription_job.doesnt.contain("Transcript") - transcription_job["Settings"]["ShowSpeakerLabels"].should.equal( + assert transcription_job["TranscriptionJobName"] == args["TranscriptionJobName"] + assert transcription_job["TranscriptionJobStatus"] == "QUEUED" + assert transcription_job["LanguageCode"] == args["LanguageCode"] + assert transcription_job["Media"] == args["Media"] + assert "CreationTime" in transcription_job + assert "StartTime" not in transcription_job + assert "CompletionTime" not in transcription_job + assert "Transcript" not in transcription_job + assert transcription_job["Settings"]["ShowSpeakerLabels"] == ( args["Settings"]["ShowSpeakerLabels"] ) - transcription_job["Settings"]["MaxSpeakerLabels"].should.equal( + assert transcription_job["Settings"]["MaxSpeakerLabels"] == ( args["Settings"]["MaxSpeakerLabels"] ) - transcription_job["Settings"]["ChannelIdentification"].should.equal( + assert transcription_job["Settings"]["ChannelIdentification"] == ( args["Settings"]["ChannelIdentification"] ) - transcription_job["Settings"]["ShowAlternatives"].should.equal( + assert transcription_job["Settings"]["ShowAlternatives"] == ( args["Settings"]["ShowAlternatives"] ) - transcription_job["Settings"]["MaxAlternatives"].should.equal( + assert transcription_job["Settings"]["MaxAlternatives"] == ( args["Settings"]["MaxAlternatives"] ) - transcription_job["Settings"]["VocabularyName"].should.equal( + assert transcription_job["Settings"]["VocabularyName"] == ( args["Settings"]["VocabularyName"] ) # IN_PROGRESS resp = client.get_transcription_job(TranscriptionJobName=job_name) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 transcription_job = resp["TranscriptionJob"] - transcription_job["TranscriptionJobStatus"].should.equal("IN_PROGRESS") - transcription_job["MediaFormat"].should.equal("flac") - transcription_job.should.contain("StartTime") - transcription_job.doesnt.contain("CompletionTime") - transcription_job.doesnt.contain("Transcript") - transcription_job["MediaSampleRateHertz"].should.equal(48000) + assert transcription_job["TranscriptionJobStatus"] == "IN_PROGRESS" + assert transcription_job["MediaFormat"] == "flac" + assert "StartTime" in transcription_job + assert "CompletionTime" not in transcription_job + assert "Transcript" not in transcription_job + assert transcription_job["MediaSampleRateHertz"] == 48000 # COMPLETED resp = client.get_transcription_job(TranscriptionJobName=job_name) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 transcription_job = resp["TranscriptionJob"] - transcription_job["TranscriptionJobStatus"].should.equal("COMPLETED") - transcription_job.should.contain("CompletionTime") - transcription_job["Transcript"].should.equal( - { - "TranscriptFileUri": f"https://s3.{region_name}.amazonaws.com/{args['OutputBucketName']}/{args['TranscriptionJobName']}.json" - } - ) + assert transcription_job["TranscriptionJobStatus"] == "COMPLETED" + assert "CompletionTime" in transcription_job + assert transcription_job["Transcript"] == { + "TranscriptFileUri": ( + f"https://s3.{region_name}.amazonaws.com" + f"/{args['OutputBucketName']}" + f"/{args['TranscriptionJobName']}.json" + ), + } @mock_transcribe @@ -272,57 +284,56 @@ def test_run_transcription_job_minimal_params(): "Media": {"MediaFileUri": "s3://my-bucket/my-media-file.wav"}, } resp = client.start_transcription_job(**args) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 transcription_job = resp["TranscriptionJob"] - transcription_job.should.contain("Settings") - transcription_job["Settings"]["ChannelIdentification"].should.equal(False) - transcription_job["Settings"]["ShowAlternatives"].should.equal(False) + assert "Settings" in transcription_job + assert transcription_job["Settings"]["ChannelIdentification"] is False + assert transcription_job["Settings"]["ShowAlternatives"] is False # CREATED resp = client.get_transcription_job(TranscriptionJobName=job_name) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 transcription_job = resp["TranscriptionJob"] - transcription_job["TranscriptionJobName"].should.equal(args["TranscriptionJobName"]) - transcription_job["TranscriptionJobStatus"].should.equal("QUEUED") - transcription_job["LanguageCode"].should.equal(args["LanguageCode"]) - transcription_job["Media"].should.equal(args["Media"]) - transcription_job.should.contain("Settings") - transcription_job["Settings"]["ChannelIdentification"].should.equal(False) - transcription_job["Settings"]["ShowAlternatives"].should.equal(False) - transcription_job.should.contain("CreationTime") - transcription_job.doesnt.contain("StartTime") - transcription_job.doesnt.contain("CompletionTime") - transcription_job.doesnt.contain("Transcript") + assert transcription_job["TranscriptionJobName"] == args["TranscriptionJobName"] + assert transcription_job["TranscriptionJobStatus"] == "QUEUED" + assert transcription_job["LanguageCode"] == args["LanguageCode"] + assert transcription_job["Media"] == args["Media"] + assert "Settings" in transcription_job + assert transcription_job["Settings"]["ChannelIdentification"] is False + assert transcription_job["Settings"]["ShowAlternatives"] is False + assert "CreationTime" in transcription_job + assert "StartTime" not in transcription_job + assert "CompletionTime" not in transcription_job + assert "Transcript" not in transcription_job # QUEUED resp = client.get_transcription_job(TranscriptionJobName=job_name) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 transcription_job = resp["TranscriptionJob"] - transcription_job["TranscriptionJobStatus"].should.equal("IN_PROGRESS") - transcription_job.should.contain("CreationTime") - transcription_job.should.contain("StartTime") - transcription_job.doesnt.contain("CompletionTime") - transcription_job.doesnt.contain("Transcript") + assert transcription_job["TranscriptionJobStatus"] == "IN_PROGRESS" + assert "CreationTime" in transcription_job + assert "StartTime" in transcription_job + assert "CompletionTime" not in transcription_job + assert "Transcript" not in transcription_job # IN_PROGESS resp = client.get_transcription_job(TranscriptionJobName=job_name) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 transcription_job = resp["TranscriptionJob"] - transcription_job["TranscriptionJobStatus"].should.equal("COMPLETED") - transcription_job.should.contain("CreationTime") - transcription_job.should.contain("StartTime") - transcription_job.should.contain("CompletionTime") - transcription_job.should.contain("Transcript") + assert transcription_job["TranscriptionJobStatus"] == "COMPLETED" + assert "CreationTime" in transcription_job + assert "StartTime" in transcription_job + assert "CompletionTime" in transcription_job + assert "Transcript" in transcription_job # Check aws hosted bucket - transcription_job["Transcript"]["TranscriptFileUri"].should.contain( + assert ( f"https://s3.{region_name}.amazonaws.com/aws-transcribe-{region_name}-prod/" - ) + ) in transcription_job["Transcript"]["TranscriptFileUri"] # Delete client.delete_transcription_job(TranscriptionJobName=job_name) - client.get_transcription_job.when.called_with( - TranscriptionJobName=job_name - ).should.throw(client.exceptions.BadRequestException) + with pytest.raises(client.exceptions.BadRequestException): + client.get_transcription_job(TranscriptionJobName=job_name) @mock_transcribe @@ -340,36 +351,36 @@ def test_run_transcription_job_s3output_params(): "OutputKey": "bucket-key", } resp = client.start_transcription_job(**args) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 # CREATED resp = client.get_transcription_job(TranscriptionJobName=job_name) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 transcription_job = resp["TranscriptionJob"] - transcription_job["TranscriptionJobName"].should.equal(args["TranscriptionJobName"]) - transcription_job["TranscriptionJobStatus"].should.equal("QUEUED") + assert transcription_job["TranscriptionJobName"] == args["TranscriptionJobName"] + assert transcription_job["TranscriptionJobStatus"] == "QUEUED" # ... already tested in test_run_transcription_job_minimal_awsoutput_params # QUEUED resp = client.get_transcription_job(TranscriptionJobName=job_name) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 transcription_job = resp["TranscriptionJob"] - transcription_job["TranscriptionJobStatus"].should.equal("IN_PROGRESS") + assert transcription_job["TranscriptionJobStatus"] == "IN_PROGRESS" # ... already tested in test_run_transcription_job_minimal_awsoutput_params # IN_PROGESS resp = client.get_transcription_job(TranscriptionJobName=job_name) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 transcription_job = resp["TranscriptionJob"] - transcription_job["TranscriptionJobStatus"].should.equal("COMPLETED") - transcription_job.should.contain("CreationTime") - transcription_job.should.contain("StartTime") - transcription_job.should.contain("CompletionTime") - transcription_job.should.contain("Transcript") + assert transcription_job["TranscriptionJobStatus"] == "COMPLETED" + assert "CreationTime" in transcription_job + assert "StartTime" in transcription_job + assert "CompletionTime" in transcription_job + assert "Transcript" in transcription_job # Check aws hosted bucket - transcription_job["Transcript"]["TranscriptFileUri"].should.contain( + assert ( "https://s3.us-east-1.amazonaws.com/my-output-bucket/bucket-key/MyJob.json" - ) + ) in transcription_job["Transcript"]["TranscriptFileUri"] # A new job without an "OutputKey" job_name = "MyJob2" args = { @@ -383,15 +394,15 @@ def test_run_transcription_job_s3output_params(): client.get_transcription_job(TranscriptionJobName=job_name) client.get_transcription_job(TranscriptionJobName=job_name) resp = client.get_transcription_job(TranscriptionJobName=job_name) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 transcription_job = resp["TranscriptionJob"] - transcription_job["TranscriptionJobStatus"].should.equal("COMPLETED") - transcription_job.should.contain("CreationTime") - transcription_job.should.contain("StartTime") - transcription_job.should.contain("CompletionTime") - transcription_job.should.contain("Transcript") + assert transcription_job["TranscriptionJobStatus"] == "COMPLETED" + assert "CreationTime" in transcription_job + assert "StartTime" in transcription_job + assert "CompletionTime" in transcription_job + assert "Transcript" in transcription_job # Check aws hosted bucket - transcription_job["Transcript"]["TranscriptFileUri"].should.equal( + assert transcription_job["Transcript"]["TranscriptFileUri"] == ( "https://s3.us-east-1.amazonaws.com/my-output-bucket/MyJob2.json" ) @@ -417,20 +428,20 @@ def test_run_transcription_job_identify_languages_params(): client.list_transcription_jobs(), # IN_PROGRESS ] for resp in resp_data: - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 if "TranscriptionJob" in resp: transcription_job = resp["TranscriptionJob"] elif "TranscriptionJobSummaries" in resp: transcription_job = resp["TranscriptionJobSummaries"][0] - transcription_job.should.contain("IdentifyLanguage") - transcription_job.should_not.contain("LanguageCodes") - transcription_job.should_not.contain("IdentifyMultipleLanguages") + assert "IdentifyLanguage" in transcription_job + assert "LanguageCodes" not in transcription_job + assert "IdentifyMultipleLanguages" not in transcription_job if "TranscriptionJobStatus" in transcription_job and ( transcription_job["TranscriptionJobStatus"] == "IN_PROGRESS" or transcription_job["TranscriptionJobStatus"] == "COMPLETED" ): - transcription_job["LanguageCode"].should.equal("en-US") - transcription_job["IdentifiedLanguageScore"].should.equal(0.999645948) + assert transcription_job["LanguageCode"] == "en-US" + assert transcription_job["IdentifiedLanguageScore"] == 0.999645948 # IdentifyMultipleLanguages job_name = "MyJob2" @@ -447,27 +458,23 @@ def test_run_transcription_job_identify_languages_params(): client.list_transcription_jobs(), # IN_PROGRESS ] for resp in resp_data: - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 if "TranscriptionJob" in resp: transcription_job = resp["TranscriptionJob"] elif "TranscriptionJobSummaries" in resp: transcription_job = resp["TranscriptionJobSummaries"][1] - transcription_job.should.contain("IdentifyMultipleLanguages") - transcription_job.should_not.contain("LanguageCode") - transcription_job.should_not.contain("IdentifyLanguage") + assert "IdentifyMultipleLanguages" in transcription_job + assert "LanguageCode" not in transcription_job + assert "IdentifyLanguage" not in transcription_job if "TranscriptionJobStatus" in transcription_job and ( transcription_job["TranscriptionJobStatus"] == "IN_PROGRESS" or transcription_job["TranscriptionJobStatus"] == "COMPLETED" ): - transcription_job["LanguageCodes"][0]["LanguageCode"].should.equal("en-US") - transcription_job["LanguageCodes"][0]["DurationInSeconds"].should.equal( - 123.0 - ) - transcription_job["LanguageCodes"][1]["LanguageCode"].should.equal("en-GB") - transcription_job["LanguageCodes"][1]["DurationInSeconds"].should.equal( - 321.0 - ) - transcription_job["IdentifiedLanguageScore"].should.equal(0.999645948) + assert transcription_job["LanguageCodes"][0]["LanguageCode"] == "en-US" + assert transcription_job["LanguageCodes"][0]["DurationInSeconds"] == 123.0 + assert transcription_job["LanguageCodes"][1]["LanguageCode"] == "en-GB" + assert transcription_job["LanguageCodes"][1]["DurationInSeconds"] == 321.0 + assert transcription_job["IdentifiedLanguageScore"] == 0.999645948 @mock_transcribe @@ -475,9 +482,10 @@ def test_get_nonexistent_medical_transcription_job(): region_name = "us-east-1" client = boto3.client("transcribe", region_name=region_name) - client.get_medical_transcription_job.when.called_with( - MedicalTranscriptionJobName="NonexistentJobName" - ).should.throw(client.exceptions.BadRequestException) + with pytest.raises(client.exceptions.BadRequestException): + client.get_medical_transcription_job( + MedicalTranscriptionJobName="NonexistentJobName" + ) @mock_transcribe @@ -485,9 +493,8 @@ def test_get_nonexistent_transcription_job(): region_name = "us-east-1" client = boto3.client("transcribe", region_name=region_name) - client.get_transcription_job.when.called_with( - TranscriptionJobName="NonexistentJobName" - ).should.throw(client.exceptions.BadRequestException) + with pytest.raises(client.exceptions.BadRequestException): + client.get_transcription_job(TranscriptionJobName="NonexistentJobName") @mock_transcribe @@ -506,11 +513,10 @@ def test_run_medical_transcription_job_with_existing_job_name(): "Type": "CONVERSATION", } resp = client.start_medical_transcription_job(**args) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 - client.start_medical_transcription_job.when.called_with(**args).should.throw( - client.exceptions.ConflictException - ) + with pytest.raises(client.exceptions.ConflictException): + client.start_medical_transcription_job(**args) @mock_transcribe @@ -526,11 +532,10 @@ def test_run_transcription_job_with_existing_job_name(): "Media": {"MediaFileUri": "s3://my-bucket/my-media-file.wav"}, } resp = client.start_transcription_job(**args) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 - client.start_transcription_job.when.called_with(**args).should.throw( - client.exceptions.ConflictException - ) + with pytest.raises(client.exceptions.ConflictException): + client.start_transcription_job(**args) @mock_transcribe @@ -549,9 +554,8 @@ def test_run_medical_transcription_job_nonexistent_vocabulary(): "Specialty": "PRIMARYCARE", "Type": "CONVERSATION", } - client.start_medical_transcription_job.when.called_with(**args).should.throw( - client.exceptions.BadRequestException - ) + with pytest.raises(client.exceptions.BadRequestException): + client.start_medical_transcription_job(**args) @mock_transcribe @@ -568,9 +572,8 @@ def test_run_transcription_job_nonexistent_vocabulary(): "OutputBucketName": "my-output-bucket", "Settings": {"VocabularyName": "NonexistentVocabulary"}, } - client.start_transcription_job.when.called_with(**args).should.throw( - client.exceptions.BadRequestException - ) + with pytest.raises(client.exceptions.BadRequestException): + client.start_transcription_job(**args) @mock_transcribe @@ -590,7 +593,7 @@ def test_list_medical_transcription_jobs(): "Type": "CONVERSATION", } resp = client.start_medical_transcription_job(**args) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 # IMPLICITLY PROMOTE JOB STATUS TO QUEUED resp = client.get_medical_transcription_job( @@ -623,46 +626,46 @@ def test_list_medical_transcription_jobs(): # List all response = client.list_medical_transcription_jobs() - response.should.contain("MedicalTranscriptionJobSummaries") - len(response["MedicalTranscriptionJobSummaries"]).should.equal(30) - response.shouldnt.contain("NextToken") - response.shouldnt.contain("Status") + assert "MedicalTranscriptionJobSummaries" in response + assert len(response["MedicalTranscriptionJobSummaries"]) == 30 + assert "NextToken" not in response + assert "Status" not in response # List IN_PROGRESS response = client.list_medical_transcription_jobs(Status="IN_PROGRESS") - response.should.contain("MedicalTranscriptionJobSummaries") - len(response["MedicalTranscriptionJobSummaries"]).should.equal(10) - response.shouldnt.contain("NextToken") - response.should.contain("Status") - response["Status"].should.equal("IN_PROGRESS") + assert "MedicalTranscriptionJobSummaries" in response + assert len(response["MedicalTranscriptionJobSummaries"]) == 10 + assert "NextToken" not in response + assert "Status" in response + assert response["Status"] == "IN_PROGRESS" # List JobName contains "8" response = client.list_medical_transcription_jobs(JobNameContains="8") - response.should.contain("MedicalTranscriptionJobSummaries") - len(response["MedicalTranscriptionJobSummaries"]).should.equal(3) - response.shouldnt.contain("NextToken") - response.shouldnt.contain("Status") + assert "MedicalTranscriptionJobSummaries" in response + assert len(response["MedicalTranscriptionJobSummaries"]) == 3 + assert "NextToken" not in response + assert "Status" not in response # Pagination by 11 response = client.list_medical_transcription_jobs(MaxResults=11) - response.should.contain("MedicalTranscriptionJobSummaries") - len(response["MedicalTranscriptionJobSummaries"]).should.equal(11) - response.should.contain("NextToken") - response.shouldnt.contain("Status") + assert "MedicalTranscriptionJobSummaries" in response + assert len(response["MedicalTranscriptionJobSummaries"]) == 11 + assert "NextToken" in response + assert "Status" not in response response = client.list_medical_transcription_jobs( NextToken=response["NextToken"], MaxResults=11 ) - response.should.contain("MedicalTranscriptionJobSummaries") - len(response["MedicalTranscriptionJobSummaries"]).should.equal(11) - response.should.contain("NextToken") + assert "MedicalTranscriptionJobSummaries" in response + assert len(response["MedicalTranscriptionJobSummaries"]) == 11 + assert "NextToken" in response response = client.list_medical_transcription_jobs( NextToken=response["NextToken"], MaxResults=11 ) - response.should.contain("MedicalTranscriptionJobSummaries") - len(response["MedicalTranscriptionJobSummaries"]).should.equal(8) - response.shouldnt.contain("NextToken") + assert "MedicalTranscriptionJobSummaries" in response + assert len(response["MedicalTranscriptionJobSummaries"]) == 8 + assert "NextToken" not in response @mock_transcribe @@ -680,7 +683,7 @@ def test_list_transcription_jobs(): "IdentifyLanguage": True, } resp = client.start_transcription_job(**args) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 # IMPLICITLY PROMOTE JOB STATUS TO QUEUED resp = client.get_transcription_job(TranscriptionJobName=job_name) @@ -707,46 +710,46 @@ def test_list_transcription_jobs(): # List all response = client.list_transcription_jobs() - response.should.contain("TranscriptionJobSummaries") - len(response["TranscriptionJobSummaries"]).should.equal(30) - response.shouldnt.contain("NextToken") - response.shouldnt.contain("Status") + assert "TranscriptionJobSummaries" in response + assert len(response["TranscriptionJobSummaries"]) == 30 + assert "NextToken" not in response + assert "Status" not in response # List IN_PROGRESS response = client.list_transcription_jobs(Status="IN_PROGRESS") - response.should.contain("TranscriptionJobSummaries") - len(response["TranscriptionJobSummaries"]).should.equal(10) - response.shouldnt.contain("NextToken") - response.should.contain("Status") - response["Status"].should.equal("IN_PROGRESS") + assert "TranscriptionJobSummaries" in response + assert len(response["TranscriptionJobSummaries"]) == 10 + assert "NextToken" not in response + assert "Status" in response + assert response["Status"] == "IN_PROGRESS" # List JobName contains "8" response = client.list_transcription_jobs(JobNameContains="8") - response.should.contain("TranscriptionJobSummaries") - len(response["TranscriptionJobSummaries"]).should.equal(3) - response.shouldnt.contain("NextToken") - response.shouldnt.contain("Status") + assert "TranscriptionJobSummaries" in response + assert len(response["TranscriptionJobSummaries"]) == 3 + assert "NextToken" not in response + assert "Status" not in response # Pagination by 11 response = client.list_transcription_jobs(MaxResults=11) - response.should.contain("TranscriptionJobSummaries") - len(response["TranscriptionJobSummaries"]).should.equal(11) - response.should.contain("NextToken") - response.shouldnt.contain("Status") + assert "TranscriptionJobSummaries" in response + assert len(response["TranscriptionJobSummaries"]) == 11 + assert "NextToken" in response + assert "Status" not in response response = client.list_transcription_jobs( NextToken=response["NextToken"], MaxResults=11 ) - response.should.contain("TranscriptionJobSummaries") - len(response["TranscriptionJobSummaries"]).should.equal(11) - response.should.contain("NextToken") + assert "TranscriptionJobSummaries" in response + assert len(response["TranscriptionJobSummaries"]) == 11 + assert "NextToken" in response response = client.list_transcription_jobs( NextToken=response["NextToken"], MaxResults=11 ) - response.should.contain("TranscriptionJobSummaries") - len(response["TranscriptionJobSummaries"]).should.equal(8) - response.shouldnt.contain("NextToken") + assert "TranscriptionJobSummaries" in response + assert len(response["TranscriptionJobSummaries"]) == 8 + assert "NextToken" not in response @mock_transcribe @@ -761,28 +764,27 @@ def test_create_medical_vocabulary(): LanguageCode="en-US", VocabularyFileUri="https://s3.us-east-1.amazonaws.com/AWSDOC-EXAMPLE-BUCKET/vocab.txt", ) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 # PENDING resp = client.get_medical_vocabulary(VocabularyName=vocabulary_name) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) - resp["VocabularyName"].should.equal(vocabulary_name) - resp["LanguageCode"].should.equal("en-US") - resp["VocabularyState"].should.equal("PENDING") - resp.should.contain("LastModifiedTime") - resp.shouldnt.contain("FailureReason") - resp["DownloadUri"].should.contain(vocabulary_name) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 + assert resp["VocabularyName"] == vocabulary_name + assert resp["LanguageCode"] == "en-US" + assert resp["VocabularyState"] == "PENDING" + assert "LastModifiedTime" in resp + assert "FailureReason" not in resp + assert vocabulary_name in resp["DownloadUri"] # IN_PROGRESS resp = client.get_medical_vocabulary(VocabularyName=vocabulary_name) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) - resp["VocabularyState"].should.equal("READY") + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 + assert resp["VocabularyState"] == "READY" # Delete client.delete_medical_vocabulary(VocabularyName=vocabulary_name) - client.get_medical_vocabulary.when.called_with( - VocabularyName=vocabulary_name - ).should.throw(client.exceptions.BadRequestException) + with pytest.raises(client.exceptions.BadRequestException): + client.get_medical_vocabulary(VocabularyName=vocabulary_name) @mock_transcribe @@ -797,28 +799,27 @@ def test_create_vocabulary(): LanguageCode="en-US", VocabularyFileUri="https://s3.us-east-1.amazonaws.com/AWSDOC-EXAMPLE-BUCKET/vocab.txt", ) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 # PENDING resp = client.get_vocabulary(VocabularyName=vocabulary_name) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) - resp["VocabularyName"].should.equal(vocabulary_name) - resp["LanguageCode"].should.equal("en-US") - resp["VocabularyState"].should.equal("PENDING") - resp.should.contain("LastModifiedTime") - resp.shouldnt.contain("FailureReason") - resp["DownloadUri"].should.contain(vocabulary_name) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 + assert resp["VocabularyName"] == vocabulary_name + assert resp["LanguageCode"] == "en-US" + assert resp["VocabularyState"] == "PENDING" + assert "LastModifiedTime" in resp + assert "FailureReason" not in resp + assert vocabulary_name in resp["DownloadUri"] # IN_PROGRESS resp = client.get_vocabulary(VocabularyName=vocabulary_name) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) - resp["VocabularyState"].should.equal("READY") + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 + assert resp["VocabularyState"] == "READY" # Delete client.delete_vocabulary(VocabularyName=vocabulary_name) - client.get_vocabulary.when.called_with(VocabularyName=vocabulary_name).should.throw( - client.exceptions.BadRequestException - ) + with pytest.raises(client.exceptions.BadRequestException): + client.get_vocabulary(VocabularyName=vocabulary_name) # Create another vocabulary with Phrases client.create_vocabulary( @@ -827,18 +828,18 @@ def test_create_vocabulary(): Phrases=["moto", "is", "awesome"], ) resp = client.get_vocabulary(VocabularyName=vocabulary_name) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) - resp["VocabularyName"].should.equal(vocabulary_name) - resp["LanguageCode"].should.equal("en-US") - resp["VocabularyState"].should.equal("PENDING") - resp["DownloadUri"].should.contain(vocabulary_name) - resp["DownloadUri"].should.contain( + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 + assert resp["VocabularyName"] == vocabulary_name + assert resp["LanguageCode"] == "en-US" + assert resp["VocabularyState"] == "PENDING" + assert vocabulary_name in resp["DownloadUri"] + assert ( f"https://s3.{region_name}.amazonaws.com/aws-transcribe-dictionary-model-{region_name}-prod" - ) + ) in resp["DownloadUri"] # IN_PROGRESS resp = client.get_vocabulary(VocabularyName=vocabulary_name) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) - resp["VocabularyState"].should.equal("READY") + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 + assert resp["VocabularyState"] == "READY" @mock_transcribe @@ -855,7 +856,7 @@ def test_list_vocabularies(): "Phrases": ["moto", "is", "awesome"], } resp = client.create_vocabulary(**args) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 # Forward to "PENDING" resp = client.get_vocabulary(VocabularyName=vocabulary_name) @@ -874,54 +875,54 @@ def test_list_vocabularies(): # List all response = client.list_vocabularies() - response.should.contain("Vocabularies") - len(response["Vocabularies"]).should.equal(15) - response.shouldnt.contain("NextToken") - response.should.contain("ResponseMetadata") + assert "Vocabularies" in response + assert len(response["Vocabularies"]) == 15 + assert "NextToken" not in response + assert "ResponseMetadata" in response # List PENDING response = client.list_vocabularies(StateEquals="PENDING") - response.should.contain("Vocabularies") - len(response["Vocabularies"]).should.equal(5) - response.shouldnt.contain("NextToken") - response.should.contain("ResponseMetadata") + assert "Vocabularies" in response + assert len(response["Vocabularies"]) == 5 + assert "NextToken" not in response + assert "ResponseMetadata" in response # List READY response = client.list_vocabularies(StateEquals="READY") - response.should.contain("Vocabularies") - len(response["Vocabularies"]).should.equal(10) - response.shouldnt.contain("NextToken") - response.should.contain("ResponseMetadata") + assert "Vocabularies" in response + assert len(response["Vocabularies"]) == 10 + assert "NextToken" not in response + assert "ResponseMetadata" in response # List VocabularyName contains "8" response = client.list_vocabularies(NameContains="8") - response.should.contain("Vocabularies") - len(response["Vocabularies"]).should.equal(1) - response.shouldnt.contain("NextToken") - response.should.contain("ResponseMetadata") + assert "Vocabularies" in response + assert len(response["Vocabularies"]) == 1 + assert "NextToken" not in response + assert "ResponseMetadata" in response # Pagination by 3 response = client.list_vocabularies(MaxResults=3) - response.should.contain("Vocabularies") - len(response["Vocabularies"]).should.equal(3) - response.should.contain("NextToken") - response.should.contain("ResponseMetadata") + assert "Vocabularies" in response + assert len(response["Vocabularies"]) == 3 + assert "NextToken" in response + assert "ResponseMetadata" in response response = client.list_vocabularies(NextToken=response["NextToken"], MaxResults=3) - response.should.contain("Vocabularies") - len(response["Vocabularies"]).should.equal(3) - response.should.contain("NextToken") - response.should.contain("ResponseMetadata") + assert "Vocabularies" in response + assert len(response["Vocabularies"]) == 3 + assert "NextToken" in response + assert "ResponseMetadata" in response response = client.list_vocabularies(NextToken=response["NextToken"], MaxResults=30) - response.should.contain("Vocabularies") - len(response["Vocabularies"]).should.equal(9) - response.shouldnt.contain("NextToken") - response.should.contain("ResponseMetadata") + assert "Vocabularies" in response + assert len(response["Vocabularies"]) == 9 + assert "NextToken" not in response + assert "ResponseMetadata" in response client.delete_vocabulary(VocabularyName="Vocab_5") response = client.list_vocabularies() - len(response["Vocabularies"]).should.equal(14) + assert len(response["Vocabularies"]) == 14 @mock_transcribe @@ -937,7 +938,7 @@ def test_list_medical_vocabularies(): LanguageCode="en-US", VocabularyFileUri="https://s3.us-east-1.amazonaws.com/AWSDOC-EXAMPLE-BUCKET/vocab.txt", ) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 # Forward to "PENDING" resp = client.get_medical_vocabulary(VocabularyName=vocabulary_name) @@ -956,58 +957,58 @@ def test_list_medical_vocabularies(): # List all response = client.list_medical_vocabularies() - response.should.contain("Vocabularies") - len(response["Vocabularies"]).should.equal(15) - response.shouldnt.contain("NextToken") - response.should.contain("ResponseMetadata") + assert "Vocabularies" in response + assert len(response["Vocabularies"]) == 15 + assert "NextToken" not in response + assert "ResponseMetadata" in response # List PENDING response = client.list_medical_vocabularies(StateEquals="PENDING") - response.should.contain("Vocabularies") - len(response["Vocabularies"]).should.equal(5) - response.shouldnt.contain("NextToken") - response.should.contain("ResponseMetadata") + assert "Vocabularies" in response + assert len(response["Vocabularies"]) == 5 + assert "NextToken" not in response + assert "ResponseMetadata" in response # List READY response = client.list_medical_vocabularies(StateEquals="READY") - response.should.contain("Vocabularies") - len(response["Vocabularies"]).should.equal(10) - response.shouldnt.contain("NextToken") - response.should.contain("ResponseMetadata") + assert "Vocabularies" in response + assert len(response["Vocabularies"]) == 10 + assert "NextToken" not in response + assert "ResponseMetadata" in response # List VocabularyName contains "8" response = client.list_medical_vocabularies(NameContains="8") - response.should.contain("Vocabularies") - len(response["Vocabularies"]).should.equal(1) - response.shouldnt.contain("NextToken") - response.should.contain("ResponseMetadata") + assert "Vocabularies" in response + assert len(response["Vocabularies"]) == 1 + assert "NextToken" not in response + assert "ResponseMetadata" in response # Pagination by 3 response = client.list_medical_vocabularies(MaxResults=3) - response.should.contain("Vocabularies") - len(response["Vocabularies"]).should.equal(3) - response.should.contain("NextToken") - response.should.contain("ResponseMetadata") + assert "Vocabularies" in response + assert len(response["Vocabularies"]) == 3 + assert "NextToken" in response + assert "ResponseMetadata" in response response = client.list_medical_vocabularies( NextToken=response["NextToken"], MaxResults=3 ) - response.should.contain("Vocabularies") - len(response["Vocabularies"]).should.equal(3) - response.should.contain("NextToken") - response.should.contain("ResponseMetadata") + assert "Vocabularies" in response + assert len(response["Vocabularies"]) == 3 + assert "NextToken" in response + assert "ResponseMetadata" in response response = client.list_medical_vocabularies( NextToken=response["NextToken"], MaxResults=30 ) - response.should.contain("Vocabularies") - len(response["Vocabularies"]).should.equal(9) - response.shouldnt.contain("NextToken") - response.should.contain("ResponseMetadata") + assert "Vocabularies" in response + assert len(response["Vocabularies"]) == 9 + assert "NextToken" not in response + assert "ResponseMetadata" in response client.delete_medical_vocabulary(VocabularyName="Vocab_5") response = client.list_medical_vocabularies() - len(response["Vocabularies"]).should.equal(14) + assert len(response["Vocabularies"]) == 14 @mock_transcribe @@ -1015,9 +1016,8 @@ def test_get_nonexistent_medical_vocabulary(): region_name = "us-east-1" client = boto3.client("transcribe", region_name=region_name) - client.get_medical_vocabulary.when.called_with( - VocabularyName="NonexistentVocabularyName" - ).should.throw(client.exceptions.BadRequestException) + with pytest.raises(client.exceptions.BadRequestException): + client.get_medical_vocabulary(VocabularyName="NonexistentVocabularyName") @mock_transcribe @@ -1025,9 +1025,8 @@ def test_get_nonexistent_vocabulary(): region_name = "us-east-1" client = boto3.client("transcribe", region_name=region_name) - client.get_vocabulary.when.called_with( - VocabularyName="NonexistentVocabularyName" - ).should.throw(client.exceptions.BadRequestException) + with pytest.raises(client.exceptions.BadRequestException): + client.get_vocabulary(VocabularyName="NonexistentVocabularyName") @mock_transcribe @@ -1043,11 +1042,10 @@ def test_create_medical_vocabulary_with_existing_vocabulary_name(): "VocabularyFileUri": "https://s3.us-east-1.amazonaws.com/AWSDOC-EXAMPLE-BUCKET/vocab.txt", } resp = client.create_medical_vocabulary(**args) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 - client.create_medical_vocabulary.when.called_with(**args).should.throw( - client.exceptions.ConflictException - ) + with pytest.raises(client.exceptions.ConflictException): + client.create_medical_vocabulary(**args) @mock_transcribe @@ -1063,11 +1061,10 @@ def test_create_vocabulary_with_existing_vocabulary_name(): "VocabularyFileUri": "https://s3.us-east-1.amazonaws.com/AWSDOC-EXAMPLE-BUCKET/vocab.txt", } resp = client.create_vocabulary(**args) - resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200) + assert resp["ResponseMetadata"]["HTTPStatusCode"] == 200 - client.create_vocabulary.when.called_with(**args).should.throw( - client.exceptions.ConflictException - ) + with pytest.raises(client.exceptions.ConflictException): + client.create_vocabulary(**args) @mock_transcribe @@ -1081,14 +1078,13 @@ def test_create_vocabulary_with_bad_request(): "VocabularyName": vocabulary_name, "LanguageCode": "en-US", } - client.create_vocabulary.when.called_with(**args).should.throw( - client.exceptions.BadRequestException - ) + with pytest.raises(client.exceptions.BadRequestException): + client.create_vocabulary(**args) + args = { "VocabularyName": vocabulary_name, "Phrases": [], "LanguageCode": "en-US", } - client.create_vocabulary.when.called_with(**args).should.throw( - client.exceptions.BadRequestException - ) + with pytest.raises(client.exceptions.BadRequestException): + client.create_vocabulary(**args)