diff --git a/TestCase/setting/test_10_team.py b/TestCase/setting/test_10_team.py index b12218f8fa4c51767b73d37043e1b35b72430be5..3e6a985745a74fb019dbbbe7de1cff0a7ec7b53a 100644 --- a/TestCase/setting/test_10_team.py +++ b/TestCase/setting/test_10_team.py @@ -2,12 +2,12 @@ import pytest from Utils import yaml_handler from Utils import req_handler from TestData.setting.team_test_data import teamData -# -# class TestTeam: -# -# yaml_path = r'setting/team.yaml' -# yaml_data = yaml_handler.yaml_handler.get_case(yaml_path) -# @pytest.mark.flaky(reruns=teamData.rerun, reruns_delay=teamData.rerun_delay) -# @pytest.mark.parametrize('case',yaml_data) -# def test_team(self,case): -# req_handler.ReqHandler.send_requests(case=case,var_class=teamData) + +class TestTeam: + + yaml_path = r'setting/team.yaml' + yaml_data = yaml_handler.yaml_handler.get_case(yaml_path) + @pytest.mark.flaky(reruns=teamData.rerun, reruns_delay=teamData.rerun_delay) + @pytest.mark.parametrize('case',yaml_data) + def test_team(self,case): + req_handler.ReqHandler.send_requests(case=case,var_class=teamData) diff --git a/TestFile/setting/tag/tag_select.py b/TestFile/setting/tag/tag_select.py index fc4dc077cda7972d49aaf06d9fca67f7e0a05793..bc26292bdf3f84e0d5b80348bf74d980fddb731c 100644 --- a/TestFile/setting/tag/tag_select.py +++ b/TestFile/setting/tag/tag_select.py @@ -6,15 +6,15 @@ if hasattr(tagData, 'tag_id'):#先判断有没有创建tag成功 pass else: insert_tag_id = data_handler.random_id() - tag_insert_sql = f"""INSERT INTO willdesk.tag (id,name,created_by,sort,status,brand_id,pid,cate,color,description,created_at,updated_at) VALUES + tag_insert_sql = f"""INSERT INTO willdesk.tag (id,`name`,created_by,sort,status,brand_id,pid,cate,color,description,created_at,updated_at) VALUES ({insert_tag_id},{tagData.tag_name},{tagData.userId},0,0,{tagData.brandId},'',0,{tagData.tag_color},{tagData.tag_description},'2024-05-06 18:05:04','2024-05-06 18:05:04'); """ test_env_conn.execute_sql(sql=tag_insert_sql) setattr(tagData, 'tag_id', insert_tag_id) - tag_select_sql = f'select * from tag where brand_id = {tagData.brandId}' tag_select_result = test_env_conn.select_many_value(sql=tag_select_sql) + tag_num = len(tag_select_result) setattr(tagData, 'tag_num', tag_num) tag_location = 1 diff --git a/TestFile/setting/team/team_select.py b/TestFile/setting/team/team_select.py index d4e01d4a26e7246c23d1ebe09266e9cbf2486b53..b11e283947a9ecaf9856de2957094232d3af5a54 100644 --- a/TestFile/setting/team/team_select.py +++ b/TestFile/setting/team/team_select.py @@ -1,6 +1,5 @@ from Utils.sql_handler import test_env_conn from TestData.setting.team_test_data import teamData - team_select_sql = f'select * from `resource_item` where brand_id = {teamData.brandId} and resource_id = 1' team_select_result = test_env_conn.select_many_value(sql=team_select_sql) if team_select_result: @@ -9,7 +8,7 @@ if team_select_result: team_id_result = test_env_conn.select_one_value(sql=team_id_select_sql) if not team_id_result: team_insert_sql = f"""INSERT INTO resource_item (name,picture,rel_id,brand_id,resource_id,sorts,is_delete,update_at,create_at) VALUES - ("{teamData.team_name}",'',0,{teamData.brandId},1,0,0,'2024-05-11 15:47:45','2024-05-11 15:47:45'); + ('{teamData.team_name}','',0,{teamData.brandId},1,0,0,'2024-05-11 15:47:45','2024-05-11 15:47:45'); """ test_env_conn.execute_sql(sql=team_insert_sql) team_id_select_sql = f'select * from `resource_item` where brand_id = {teamData.brandId} and name = "{teamData.team_name}"' @@ -22,7 +21,7 @@ if team_select_result: else: team_insert_sql = f"""INSERT INTO resource_item (name,picture,rel_id,brand_id,resource_id,sorts,is_delete,update_at,create_at) VALUES - ("{teamData.team_name}",'',0,{teamData.brandId},1,0,0,'2024-05-11 15:47:45','2024-05-11 15:47:45'); + ('{teamData.team_name}','',0,{teamData.brandId},1,0,0,'2024-05-11 15:47:45','2024-05-11 15:47:45'); """ test_env_conn.execute_sql(sql=team_insert_sql) team_id_select_sql = f'select * from `resource_item` where brand_id = {teamData.brandId} and name = "{teamData.team_name}"' diff --git a/TestFile/setting/team/teammate_select.py b/TestFile/setting/team/teammate_select.py index abce9949a1dd909e58ff9b9b069b6fcc7628606c..e76625875eaa0e851e0168ddbfe5bacb5951ee84 100644 --- a/TestFile/setting/team/teammate_select.py +++ b/TestFile/setting/team/teammate_select.py @@ -1,8 +1,11 @@ from Utils.sql_handler import test_env_conn from TestData.setting.team_test_data import teamData + +global teamData +global test_env_conn def insert_teammate(): - teammate_insert_sql = f"""INSERT INTO `customer_service` (email,password,name,profile,is_update_password,is_open_window,enter_type,customer_type,local_lang,is_delete,create_at,update_at) VALUES - ("{teamData.teammate_email}",'','','',0,1,1,0,'',0,1715397311,1715409940); + teammate_insert_sql = f"""INSERT INTO `customer_service` (email,password,`name`,profile,is_update_password,is_open_window,enter_type,customer_type,local_lang,is_delete,create_at,update_at) VALUES + ('{teamData.teammate_email}','','','',0,1,1,0,'',0,1715397311,1715409940); """ test_env_conn.execute_sql(sql=teammate_insert_sql) teammate_id_select_sql = f'select * from customer_service where email = "{teamData.teammate_email}"' @@ -23,6 +26,7 @@ def insert_teammate(): setattr(teamData, 'teammate_id', teammate_id) + team_id_list_select_sql = f'select id from `resource_item` where brand_id = {teamData.brandId} and resource_id in (0,1)' team_id_list_select_result = test_env_conn.select_many_value(sql=team_id_list_select_sql) team_id_list = tuple([team_id['id'] for team_id in team_id_list_select_result]) diff --git a/Utils/req_handler.py b/Utils/req_handler.py index de18186878c11e91f96eda3ba9829c03ada3da4b..ada93f6bd62651bb56c68858b5474d9117a82053 100644 --- a/Utils/req_handler.py +++ b/Utils/req_handler.py @@ -189,6 +189,9 @@ class ReqHandler: except AssertionError: print(f'期望值为{value}({type(value)}),实际返回值为{res_path_value}({type(res_path_value)}),完整的expected体为{expected}') raise AssertionError + except Exception: + print(f'返回值:{res.text}') + raise Exception def set_value_handler(self,res,item,var_class): ''' :param res: 传response请求体 diff --git a/YamlCase/setting/tag.yaml b/YamlCase/setting/tag.yaml index 5bbf54bca19a669a849811a160a02ee604996733..c37e9a3d95ced3a018e03495cc26f31cc1b2c70b 100644 --- a/YamlCase/setting/tag.yaml +++ b/YamlCase/setting/tag.yaml @@ -90,6 +90,7 @@ api10: url: /api/v1/resource/tag/deleteTag method: post data: {"id":"${tag_id}","v":"${v}"} + sleep: 1 expected: - eq: {"$.code" : 0}