2025-04-11 09:40:32 +08:00

80 lines
2.4 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# coding:utf-8
import os
import time
import pytest
import allure
import serial
import datetime
import argparse
import serial.tools.list_ports
from PyEcLib.PyATLib import EcATCmdTester
DEFAULT_BAUD='115200'
DEFAULT_PORT='COM29'
PLAY_8K_CMD = b'{"name":"systest_play_mp3","param1":0,"param2":0,"param3":"C:/NetConnetOk_8000_32000_576.mp3"}\r'
splist = list(serial.tools.list_ports.comports())
ser = serial.Serial(DEFAULT_PORT, DEFAULT_BAUD, bytesize=8, parity='N', stopbits=1, rtscts=1, timeout=5)
if ser.is_open == True:
ser.close()
ser.open()
time.sleep(1)
ser_hold.rts=1
time.sleep(1)
ser_hold.rts=0
time.sleep(1)
fd = open("commtest_log.txt", 'w')
EcTester = EcATCmdTester(ser, 3)
nowtime=datetime.datetime.now()
print("test time:"+nowtime.strftime('%Y-%m-%d %H:%M:%S'))
EcTester.EC_Version()
EcTester.EC_LogtoFile(fd,True)
EcTester.EC_LOG('...Commtest Test Start...')
def Audio_P_CMD(ser,key):
no_ret_cmd(ser,PLAY_8K_CMD)
no_ret_cmd(ser,key)
no_ret_cmd(ser,PLAY_8K_CMD)
def no_ret_cmd(ser,cmd):
ser.write(cmd)
# setup_module 在当前模块下所有test执行之前执行。
def setup_module(module):
print("\n--------------------setup_module--------------------")
# testdown_module 在当前模块下所有test执行之前执行。
def teardown_module(module):
print ("\n--------------------teardown_module--------------------")
# 在每个test之前,均执行。
def setup_function(function):
print("<-------------------------------------------------setup_function------>")
# 在每个test之后,均执行。
def teardown_function(function):
print ("<-------------------------------------------------teardown_function--->")
AT=b'AT\r\n'
#@pytest.mark.repeat(1)
@pytest.mark.run(order=1)
@allure.feature('基本功能测试')
@allure.story('Audio 8K')
@allure.title("Audio 8K")
#severity:blocker/critical/major/normal 优先级
@allure.severity("blocker")
def test0():
print('run test0 -- test audio')
print("test time:"+nowtime.strftime('%Y-%m-%d %H:%M:%S'))
no_ret_cmd(ser, PLAY_8K_CMD)
result = EcTester.EC_PollString('p_systest_json->p_param3: C:/NetConnetOk_8000_32000_576.mp3',10)
EcTester.EC_LOG("result = "+str(result[1]))
if(result[0] == True):
EcTester.EC_LOG('test audio ...................................OK')
return True
EcTester.EC_LOG('test audio ...................................Fail!')
assert 'success' == 'failed'
return False