How to use create_medical_vocabulary method in localstack

Best Python code snippet using localstack_python

test_transcribe_boto3.py

Source:test_transcribe_boto3.py Github

copy

Full Screen

...70def test_run_medical_transcription_job_all_params():71 region_name = "us-east-1"72 client = boto3.client("transcribe", region_name=region_name)73 vocabulary_name = "MyMedicalVocabulary"74 resp = client.create_medical_vocabulary(75 VocabularyName=vocabulary_name,76 LanguageCode="en-US",77 VocabularyFileUri="https://s3.us-east-1.amazonaws.com/AWSDOC-EXAMPLE-BUCKET/vocab.txt",78 )79 resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)80 job_name = "MyJob2"81 args = {82 "MedicalTranscriptionJobName": job_name,83 "LanguageCode": "en-US",84 "MediaSampleRateHertz": 48000,85 "MediaFormat": "flac",86 "Media": {"MediaFileUri": "s3://my-bucket/my-media-file.dat",},87 "OutputBucketName": "my-output-bucket",88 "OutputEncryptionKMSKeyId": "arn:aws:kms:us-east-1:012345678901:key/37111b5e-8eff-4706-ae3a-d4f9d1d559fc",89 "Settings": {90 "ShowSpeakerLabels": True,91 "MaxSpeakerLabels": 5,92 "ChannelIdentification": True,93 "ShowAlternatives": True,94 "MaxAlternatives": 6,95 "VocabularyName": vocabulary_name,96 },97 "Specialty": "PRIMARYCARE",98 "Type": "CONVERSATION",99 }100 resp = client.start_medical_transcription_job(**args)101 resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)102 # CREATED103 resp = client.get_medical_transcription_job(MedicalTranscriptionJobName=job_name)104 resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)105 transcription_job = resp["MedicalTranscriptionJob"]106 transcription_job["MedicalTranscriptionJobName"].should.equal(107 args["MedicalTranscriptionJobName"]108 )109 transcription_job["TranscriptionJobStatus"].should.equal("QUEUED")110 transcription_job["LanguageCode"].should.equal(args["LanguageCode"])111 transcription_job["Media"].should.equal(args["Media"])112 transcription_job.should.contain("CreationTime")113 transcription_job.doesnt.contain("StartTime")114 transcription_job.doesnt.contain("CompletionTime")115 transcription_job.doesnt.contain("Transcript")116 transcription_job["Settings"]["ShowSpeakerLabels"].should.equal(117 args["Settings"]["ShowSpeakerLabels"]118 )119 transcription_job["Settings"]["MaxSpeakerLabels"].should.equal(120 args["Settings"]["MaxSpeakerLabels"]121 )122 transcription_job["Settings"]["ChannelIdentification"].should.equal(123 args["Settings"]["ChannelIdentification"]124 )125 transcription_job["Settings"]["ShowAlternatives"].should.equal(126 args["Settings"]["ShowAlternatives"]127 )128 transcription_job["Settings"]["MaxAlternatives"].should.equal(129 args["Settings"]["MaxAlternatives"]130 )131 transcription_job["Settings"]["VocabularyName"].should.equal(132 args["Settings"]["VocabularyName"]133 )134 transcription_job["Specialty"].should.equal(args["Specialty"])135 transcription_job["Type"].should.equal(args["Type"])136 # IN_PROGRESS137 resp = client.get_medical_transcription_job(MedicalTranscriptionJobName=job_name)138 resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)139 transcription_job = resp["MedicalTranscriptionJob"]140 transcription_job["TranscriptionJobStatus"].should.equal("IN_PROGRESS")141 transcription_job["MediaFormat"].should.equal("flac")142 transcription_job.should.contain("StartTime")143 transcription_job.doesnt.contain("CompletionTime")144 transcription_job.doesnt.contain("Transcript")145 transcription_job["MediaSampleRateHertz"].should.equal(48000)146 # COMPLETED147 resp = client.get_medical_transcription_job(MedicalTranscriptionJobName=job_name)148 resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)149 transcription_job = resp["MedicalTranscriptionJob"]150 transcription_job["TranscriptionJobStatus"].should.equal("COMPLETED")151 transcription_job.should.contain("CompletionTime")152 transcription_job["Transcript"].should.equal(153 {154 "TranscriptFileUri": "https://s3.{}.amazonaws.com/{}/medical/{}.json".format(155 region_name,156 args["OutputBucketName"],157 args["MedicalTranscriptionJobName"],158 )159 }160 )161@mock_transcribe162def test_get_nonexistent_medical_transcription_job():163 region_name = "us-east-1"164 client = boto3.client("transcribe", region_name=region_name)165 client.get_medical_transcription_job.when.called_with(166 MedicalTranscriptionJobName="NonexistentJobName"167 ).should.throw(client.exceptions.BadRequestException)168@mock_transcribe169def test_run_medical_transcription_job_with_existing_job_name():170 region_name = "us-east-1"171 client = boto3.client("transcribe", region_name=region_name)172 job_name = "MyJob"173 args = {174 "MedicalTranscriptionJobName": job_name,175 "LanguageCode": "en-US",176 "Media": {"MediaFileUri": "s3://my-bucket/my-media-file.wav",},177 "OutputBucketName": "my-output-bucket",178 "Specialty": "PRIMARYCARE",179 "Type": "CONVERSATION",180 }181 resp = client.start_medical_transcription_job(**args)182 resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)183 client.start_medical_transcription_job.when.called_with(**args).should.throw(184 client.exceptions.ConflictException185 )186@mock_transcribe187def test_run_medical_transcription_job_nonexistent_vocabulary():188 region_name = "us-east-1"189 client = boto3.client("transcribe", region_name=region_name)190 job_name = "MyJob3"191 args = {192 "MedicalTranscriptionJobName": job_name,193 "LanguageCode": "en-US",194 "Media": {"MediaFileUri": "s3://my-bucket/my-media-file.dat",},195 "OutputBucketName": "my-output-bucket",196 "Settings": {"VocabularyName": "NonexistentVocabulary"},197 "Specialty": "PRIMARYCARE",198 "Type": "CONVERSATION",199 }200 client.start_medical_transcription_job.when.called_with(**args).should.throw(201 client.exceptions.BadRequestException202 )203@mock_transcribe204def test_list_medical_transcription_jobs():205 region_name = "us-east-1"206 client = boto3.client("transcribe", region_name=region_name)207 def run_job(index, target_status):208 job_name = "Job_{}".format(index)209 args = {210 "MedicalTranscriptionJobName": job_name,211 "LanguageCode": "en-US",212 "Media": {"MediaFileUri": "s3://my-bucket/my-media-file.wav",},213 "OutputBucketName": "my-output-bucket",214 "Specialty": "PRIMARYCARE",215 "Type": "CONVERSATION",216 }217 resp = client.start_medical_transcription_job(**args)218 resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)219 # IMPLICITLY PROMOTE JOB STATUS TO QUEUED220 resp = client.get_medical_transcription_job(221 MedicalTranscriptionJobName=job_name222 )223 # IN_PROGRESS224 if target_status in ["IN_PROGRESS", "COMPLETED"]:225 resp = client.get_medical_transcription_job(226 MedicalTranscriptionJobName=job_name227 )228 # COMPLETED229 if target_status == "COMPLETED":230 resp = client.get_medical_transcription_job(231 MedicalTranscriptionJobName=job_name232 )233 # Run 5 pending jobs234 for i in range(5):235 run_job(i, "PENDING")236 # Run 10 job to IN_PROGRESS237 for i in range(5, 15):238 run_job(i, "IN_PROGRESS")239 # Run 15 job to COMPLETED240 for i in range(15, 30):241 run_job(i, "COMPLETED")242 # List all243 response = client.list_medical_transcription_jobs()244 response.should.contain("MedicalTranscriptionJobSummaries")245 len(response["MedicalTranscriptionJobSummaries"]).should.equal(30)246 response.shouldnt.contain("NextToken")247 response.shouldnt.contain("Status")248 # List IN_PROGRESS249 response = client.list_medical_transcription_jobs(Status="IN_PROGRESS")250 response.should.contain("MedicalTranscriptionJobSummaries")251 len(response["MedicalTranscriptionJobSummaries"]).should.equal(10)252 response.shouldnt.contain("NextToken")253 response.should.contain("Status")254 response["Status"].should.equal("IN_PROGRESS")255 # List JobName contains "8"256 response = client.list_medical_transcription_jobs(JobNameContains="8")257 response.should.contain("MedicalTranscriptionJobSummaries")258 len(response["MedicalTranscriptionJobSummaries"]).should.equal(3)259 response.shouldnt.contain("NextToken")260 response.shouldnt.contain("Status")261 # Pagination by 11262 response = client.list_medical_transcription_jobs(MaxResults=11)263 response.should.contain("MedicalTranscriptionJobSummaries")264 len(response["MedicalTranscriptionJobSummaries"]).should.equal(11)265 response.should.contain("NextToken")266 response.shouldnt.contain("Status")267 response = client.list_medical_transcription_jobs(268 NextToken=response["NextToken"], MaxResults=11269 )270 response.should.contain("MedicalTranscriptionJobSummaries")271 len(response["MedicalTranscriptionJobSummaries"]).should.equal(11)272 response.should.contain("NextToken")273 response = client.list_medical_transcription_jobs(274 NextToken=response["NextToken"], MaxResults=11275 )276 response.should.contain("MedicalTranscriptionJobSummaries")277 len(response["MedicalTranscriptionJobSummaries"]).should.equal(8)278 response.shouldnt.contain("NextToken")279@mock_transcribe280def test_create_medical_vocabulary():281 region_name = "us-east-1"282 client = boto3.client("transcribe", region_name=region_name)283 vocabulary_name = "MyVocabulary"284 resp = client.create_medical_vocabulary(285 VocabularyName=vocabulary_name,286 LanguageCode="en-US",287 VocabularyFileUri="https://s3.us-east-1.amazonaws.com/AWSDOC-EXAMPLE-BUCKET/vocab.txt",288 )289 resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)290 # PENDING291 resp = client.get_medical_vocabulary(VocabularyName=vocabulary_name)292 resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)293 resp["VocabularyName"].should.equal(vocabulary_name)294 resp["LanguageCode"].should.equal("en-US")295 resp["VocabularyState"].should.equal("PENDING")296 resp.should.contain("LastModifiedTime")297 resp.shouldnt.contain("FailureReason")298 resp["DownloadUri"].should.contain(vocabulary_name)299 # IN_PROGRESS300 resp = client.get_medical_vocabulary(VocabularyName=vocabulary_name)301 resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)302 resp["VocabularyState"].should.equal("READY")303 # Delete304 client.delete_medical_vocabulary(VocabularyName=vocabulary_name)305 client.get_medical_vocabulary.when.called_with(306 VocabularyName=vocabulary_name307 ).should.throw(client.exceptions.BadRequestException)308@mock_transcribe309def test_get_nonexistent_medical_vocabulary():310 region_name = "us-east-1"311 client = boto3.client("transcribe", region_name=region_name)312 client.get_medical_vocabulary.when.called_with(313 VocabularyName="NonexistentVocabularyName"314 ).should.throw(client.exceptions.BadRequestException)315@mock_transcribe316def test_create_medical_vocabulary_with_existing_vocabulary_name():317 region_name = "us-east-1"318 client = boto3.client("transcribe", region_name=region_name)319 vocabulary_name = "MyVocabulary"320 args = {321 "VocabularyName": vocabulary_name,322 "LanguageCode": "en-US",323 "VocabularyFileUri": "https://s3.us-east-1.amazonaws.com/AWSDOC-EXAMPLE-BUCKET/vocab.txt",324 }325 resp = client.create_medical_vocabulary(**args)326 resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)327 client.create_medical_vocabulary.when.called_with(**args).should.throw(328 client.exceptions.ConflictException...

Full Screen

Full Screen

responses.py

Source:responses.py Github

copy

Full Screen

...56 medical_transcription_job_name=medical_transcription_job_name57 )58 return json.dumps(response)59 @amzn_request_id60 def create_medical_vocabulary(self):61 vocabulary_name = self._get_param("VocabularyName")62 language_code = self._get_param("LanguageCode")63 vocabulary_file_uri = self._get_param("VocabularyFileUri")64 response = self.transcribe_backend.create_medical_vocabulary(65 vocabulary_name=vocabulary_name,66 language_code=language_code,67 vocabulary_file_uri=vocabulary_file_uri,68 )69 return json.dumps(response)70 @amzn_request_id71 def get_medical_vocabulary(self):72 vocabulary_name = self._get_param("VocabularyName")73 response = self.transcribe_backend.get_medical_vocabulary(74 vocabulary_name=vocabulary_name75 )76 return json.dumps(response)77 @amzn_request_id78 def list_medical_vocabularies(self):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful