Skip to content

Commit

Permalink
Merge pull request #299 from l-iberty/master
Browse files Browse the repository at this point in the history
ut
  • Loading branch information
l-iberty authored Feb 6, 2025
2 parents 856eaeb + 8101d44 commit 0d1301d
Showing 1 changed file with 74 additions and 22 deletions.
96 changes: 74 additions & 22 deletions ut/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import time
import hashlib
import os
from urllib.parse import urlencode, quote

import requests
import json
Expand Down Expand Up @@ -101,6 +100,7 @@ def token(self):
mi_face_search_dataset_name = "ci-sdk-face-search"
mi_face_search_file = "face.jpeg"


def _create_test_bucket(test_bucket, create_region=None):
try:
if create_region is None:
Expand Down Expand Up @@ -3619,6 +3619,13 @@ def test_append_object():


def test_ci_delete_asr_template():
response = client.ci_get_asr_bucket(BucketName=ci_bucket_name)
if response['TotalCount'] == '0':
kwargs = {"CacheControl": "no-cache", "ResponseCacheControl": "no-cache"}
client.ci_open_asr_bucket(
Bucket=ci_bucket_name,
**kwargs
)
# 删除指定语音识别模板
response = client.ci_delete_asr_template(
Bucket=ci_bucket_name,
Expand All @@ -3629,6 +3636,13 @@ def test_ci_delete_asr_template():

def test_ci_get_asr_template():
# 获取语音识别模板
response = client.ci_get_asr_bucket(BucketName=ci_bucket_name)
if response['TotalCount'] == '0':
kwargs = {"CacheControl": "no-cache", "ResponseCacheControl": "no-cache"}
client.ci_open_asr_bucket(
Bucket=ci_bucket_name,
**kwargs
)
kwargs = {"ContentType": "application/xml",
"ResponseCacheControl": "no-cache"}
response = client.ci_get_asr_template(
Expand All @@ -3640,6 +3654,11 @@ def test_ci_get_asr_template():

def test_ci_create_asr_template():
# 创建语音识别模板
response = client.ci_get_asr_bucket(BucketName=ci_bucket_name)
if response['TotalCount'] == '0':
client.ci_open_asr_bucket(
Bucket=ci_bucket_name,
)
kwargs = {"CacheControl": "no-cache", "ResponseCacheControl": "no-cache"}
response = client.ci_create_asr_template(
Bucket=ci_bucket_name,
Expand Down Expand Up @@ -3679,6 +3698,11 @@ def test_ci_create_asr_template():


def test_ci_list_asr_jobs():
response = client.ci_get_asr_bucket(BucketName=ci_bucket_name)
if response['TotalCount'] == '0':
client.ci_open_asr_bucket(
Bucket=ci_bucket_name,
)
kwargs = {"ContentType": "application/xml",
"ResponseCacheControl": "no-cache"}
response = client.ci_get_asr_queue(
Expand All @@ -3704,6 +3728,11 @@ def test_ci_list_asr_jobs():

def test_ci_get_asr_jobs():
# 获取语音识别任务信息
response = client.ci_get_asr_bucket(BucketName=ci_bucket_name)
if response['TotalCount'] == '0':
client.ci_open_asr_bucket(
Bucket=ci_bucket_name,
)
kwargs = {"CacheControl": "no-cache", "ResponseCacheControl": "no-cache"}
response = client.ci_get_asr_job(
Bucket=ci_bucket_name,
Expand All @@ -3714,6 +3743,11 @@ def test_ci_get_asr_jobs():


def test_ci_create_asr_jobs():
response = client.ci_get_asr_bucket(BucketName=ci_bucket_name)
if response['TotalCount'] == '0':
client.ci_open_asr_bucket(
Bucket=ci_bucket_name,
)
response = client.ci_get_asr_queue(
Bucket=ci_bucket_name,
ContentType='application/xml'
Expand Down Expand Up @@ -3749,6 +3783,11 @@ def test_ci_create_asr_jobs():


def test_ci_put_asr_queue():
response = client.ci_get_asr_bucket(BucketName=ci_bucket_name)
if response['TotalCount'] == '0':
client.ci_open_asr_bucket(
Bucket=ci_bucket_name,
)
response = client.ci_get_asr_queue(
Bucket=ci_bucket_name,
)
Expand Down Expand Up @@ -3777,6 +3816,11 @@ def test_ci_put_asr_queue():

def test_ci_get_asr_queue():
# 查询语音识别队列信息
response = client.ci_get_asr_bucket(BucketName=ci_bucket_name)
if response['TotalCount'] == '0':
client.ci_open_asr_bucket(
Bucket=ci_bucket_name,
)
response = client.ci_get_asr_queue(
Bucket=ci_bucket_name,
)
Expand Down Expand Up @@ -4761,11 +4805,19 @@ def test_put_get_async_fetch_task():
},
)
time.sleep(3)
response2 = tmp_client.get_async_fetch_task(
Bucket=test_bucket,
TaskId=response['data']['taskid'],
)
assert response2['message'] == 'SUCCESS'
taskId = 'test_taskid'
if 'data' in response:
taskId = response['data']['taskid']
response2 = tmp_client.get_async_fetch_task(
Bucket=test_bucket,
TaskId=taskId,
)
assert response2['message'] == 'SUCCESS'
else:
response2 = tmp_client.get_async_fetch_task(
Bucket=test_bucket,
TaskId=taskId,
)


def test_get_rtmp_signed_url():
Expand Down Expand Up @@ -5910,22 +5962,6 @@ def test_ci_ai_bucket():
assert data['AiBucket']['Name'] == ci_bucket_name


def test_ci_asr_bucket():
# 关闭智能语音服务
kwargs = {"CacheControl": "no-cache", "ResponseCacheControl": "no-cache"}
response, data = client.ci_close_asr_bucket(
Bucket=ci_bucket_name,
**kwargs
)
assert data['BucketName'] == ci_bucket_name

response, data = client.ci_open_asr_bucket(
Bucket=ci_bucket_name,
**kwargs
)
assert data['AsrBucket']['Name'] == ci_bucket_name


def test_ci_hls_play_key():
kwargs = {"CacheControl": "no-cache", "ResponseCacheControl": "no-cache"}

Expand Down Expand Up @@ -5961,6 +5997,22 @@ def test_ci_hls_play_key():
assert data['PlayKeyList']['BackupPlayKey'] == '128d75fd2b6b4f958ccbb6fc38f60f04'


def test_ci_asr_bucket():
# 关闭智能语音服务
kwargs = {"CacheControl": "no-cache", "ResponseCacheControl": "no-cache"}
response, data = client.ci_close_asr_bucket(
Bucket=ci_bucket_name,
**kwargs
)
assert data['BucketName'] == ci_bucket_name

response, data = client.ci_open_asr_bucket(
Bucket=ci_bucket_name,
**kwargs
)
assert data['AsrBucket']['Name'] == ci_bucket_name


if __name__ == "__main__":
setUp()
"""
Expand Down

0 comments on commit 0d1301d

Please sign in to comment.