From 2adc9e7ab781175fd9135078c0ceee102d6429cc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=AF=9B=E9=B9=8F?= <729164035@qq.com>
Date: Wed, 31 Jul 2024 18:26:58 +0800
Subject: [PATCH 01/15] =?UTF-8?q?=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../PyAutoTest/auto_test/auto_system/apps.py | 51 +++++++++++--------
.../service/management/scan_table.py | 35 -------------
.../scan_table.py} | 7 +++
MangoServer/PyAutoTest/settings/__init__.py | 7 +--
4 files changed, 39 insertions(+), 61 deletions(-)
delete mode 100644 MangoServer/PyAutoTest/auto_test/auto_system/service/management/scan_table.py
rename MangoServer/PyAutoTest/auto_test/auto_system/service/{management/__init__.py => scheduled_tasks/scan_table.py} (32%)
diff --git a/MangoServer/PyAutoTest/auto_test/auto_system/apps.py b/MangoServer/PyAutoTest/auto_test/auto_system/apps.py
index 454dabd3..98ed0160 100644
--- a/MangoServer/PyAutoTest/auto_test/auto_system/apps.py
+++ b/MangoServer/PyAutoTest/auto_test/auto_system/apps.py
@@ -3,15 +3,15 @@
# @Description:
# @Time : 2023/1/17 10:20
# @Author : 毛鹏
-
-import logging
+import os
import threading
import time
+from apscheduler.schedulers.background import BackgroundScheduler
from django.apps import AppConfig
from django.db import ProgrammingError, OperationalError
-log = logging.getLogger('system')
+from PyAutoTest.tools.log_collector import log
class AutoSystemConfig(AppConfig):
@@ -19,20 +19,31 @@ class AutoSystemConfig(AppConfig):
name = 'PyAutoTest.auto_test.auto_system'
def ready(self):
- def delayed_task():
- time.sleep(10)
- try:
- from PyAutoTest.auto_test.auto_system.service.scheduled_tasks.tasks import Tasks
- Tasks.create_jobs()
- except OperationalError:
- pass
- except RuntimeError:
- pass
- except ProgrammingError:
- log.error(
- '请先迁移数据库再运行服务!!!如果正在迁移请忽略~')
- raise Exception(
- '请先迁移数据库再运行服务!!!如果正在迁移请忽略~')
-
- delayed_thread = threading.Thread(target=delayed_task)
- delayed_thread.start()
+ def run():
+ time.sleep(5)
+ self.minute_task()
+ self.delayed_task()
+
+ if os.environ.get('RUN_MAIN', None) == 'true':
+ task1 = threading.Thread(target=run)
+ task1.start()
+
+ @staticmethod
+ def minute_task():
+ from PyAutoTest.auto_test.auto_system.service.scheduled_tasks.scan_table import mytask
+ sched = BackgroundScheduler()
+ sched.add_job(mytask, 'interval', seconds=60)
+ sched.start()
+
+ @staticmethod
+ def delayed_task():
+ try:
+ from PyAutoTest.auto_test.auto_system.service.scheduled_tasks.tasks import Tasks
+ Tasks.create_jobs()
+ except OperationalError:
+ pass
+ except RuntimeError:
+ pass
+ except ProgrammingError:
+ log.system.error('请先迁移数据库再运行服务!!!如果正在迁移请忽略~')
+ raise Exception('请先迁移数据库再运行服务!!!如果正在迁移请忽略~')
diff --git a/MangoServer/PyAutoTest/auto_test/auto_system/service/management/scan_table.py b/MangoServer/PyAutoTest/auto_test/auto_system/service/management/scan_table.py
deleted file mode 100644
index 91179af0..00000000
--- a/MangoServer/PyAutoTest/auto_test/auto_system/service/management/scan_table.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# -*- coding: utf-8 -*-
-# @Project: auto_test
-# @Description:
-# @Time : 2024-07-30 上午11:41
-# @Author : 毛鹏
-from django.core.management.base import BaseCommand
-from django.utils import timezone
-from PyAutoTest.auto_test.auto_ui.models import UiCase
-import threading
-from django.core.management.base import BaseCommand
-from django.utils import timezone
-from croniter import croniter
-import threading
-
-def execute_task(cron_expression):
- # 在这里执行你的任务
- print(f"执行任务: {cron_expression}")
-
-class Command(BaseCommand):
- help = '每分钟检查 Cron 表达式'
-
- def handle(self, *args, **kwargs):
- current_time = timezone.now()
- records = UiCase.objects.all() # 获取所有记录
-
- for record in records:
- print(record.name)
- # cron_expression = record.cron # 假设你的模型有一个 cron 字段
- # cron = croniter(cron_expression, current_time)
- #
- # # 检查当前时间是否符合 Cron 表达式
- # if cron.get_next() == current_time:
- # threading.Thread(target=execute_task, args=(cron_expression,)).start()
-
- print(f"扫描时间: {current_time}")
diff --git a/MangoServer/PyAutoTest/auto_test/auto_system/service/management/__init__.py b/MangoServer/PyAutoTest/auto_test/auto_system/service/scheduled_tasks/scan_table.py
similarity index 32%
rename from MangoServer/PyAutoTest/auto_test/auto_system/service/management/__init__.py
rename to MangoServer/PyAutoTest/auto_test/auto_system/service/scheduled_tasks/scan_table.py
index 987acb02..83e298e8 100644
--- a/MangoServer/PyAutoTest/auto_test/auto_system/service/management/__init__.py
+++ b/MangoServer/PyAutoTest/auto_test/auto_system/service/scheduled_tasks/scan_table.py
@@ -3,3 +3,10 @@
# @Description:
# @Time : 2024-07-30 上午11:41
# @Author : 毛鹏
+from apscheduler.schedulers.background import BackgroundScheduler
+import time
+sched = BackgroundScheduler()
+
+@sched.scheduled_job('interval', seconds=30) # 表示间隔一分钟会执行函数
+def mytask():
+ print(f'{time.time()}次要任务')
diff --git a/MangoServer/PyAutoTest/settings/__init__.py b/MangoServer/PyAutoTest/settings/__init__.py
index c52de3c5..4ab2a818 100644
--- a/MangoServer/PyAutoTest/settings/__init__.py
+++ b/MangoServer/PyAutoTest/settings/__init__.py
@@ -44,7 +44,6 @@ INSTALLED_APPS = [
'rest_framework', # 前后端分离
'corsheaders', # 跨域
'channels', # 验证
- 'django_crontab', # 任务
]
MIDDLEWARE = [
@@ -268,8 +267,4 @@ CORS_ALLOW_METHODS = (
'POST',
'PUT',
'VIEW',
-)
-
-CRONJOBS = [
- ('* * * * *', 'PyAutoTest.auto_test.auto_system.service.management.scan_table'), # 替换为你的应用名
-]
+)
\ No newline at end of file
--
Gitee
From df2bc7efec3d754d65976b92f4c9bab67fe86d62 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=AF=9B=E9=B9=8F?= <729164035@qq.com>
Date: Thu, 1 Aug 2024 14:06:08 +0800
Subject: [PATCH 02/15] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=89=8D=E7=AB=AF?=
=?UTF-8?q?=E5=BC=82=E5=B8=B8=E6=97=A5=E5=BF=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../service/scheduled_tasks/scan_table.py | 2 +-
.../tools/decorator/error_response.py | 19 +++++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/MangoServer/PyAutoTest/auto_test/auto_system/service/scheduled_tasks/scan_table.py b/MangoServer/PyAutoTest/auto_test/auto_system/service/scheduled_tasks/scan_table.py
index 83e298e8..5a8631a0 100644
--- a/MangoServer/PyAutoTest/auto_test/auto_system/service/scheduled_tasks/scan_table.py
+++ b/MangoServer/PyAutoTest/auto_test/auto_system/service/scheduled_tasks/scan_table.py
@@ -9,4 +9,4 @@ sched = BackgroundScheduler()
@sched.scheduled_job('interval', seconds=30) # 表示间隔一分钟会执行函数
def mytask():
- print(f'{time.time()}次要任务')
+ pass
diff --git a/MangoServer/PyAutoTest/tools/decorator/error_response.py b/MangoServer/PyAutoTest/tools/decorator/error_response.py
index 4aeca0c4..2d2f675f 100644
--- a/MangoServer/PyAutoTest/tools/decorator/error_response.py
+++ b/MangoServer/PyAutoTest/tools/decorator/error_response.py
@@ -4,9 +4,11 @@
# @Time : 2024-07-25 上午9:55
# @Author : 毛鹏
import traceback
+from datetime import datetime
from rest_framework.request import Request
+from PyAutoTest.auto_test.auto_system.service.notic_tools import NoticeMain
from PyAutoTest.exceptions import MangoServerError
from PyAutoTest.tools.log_collector import log
from PyAutoTest.tools.view.error_msg import ERROR_MSG_0000
@@ -36,6 +38,23 @@ def error_response(app: str):
except Exception as error:
trace = traceback.format_exc()
log_dict.get(app, log.system).error(f'错误内容:{error}-错误详情:{trace}')
+ content = f"""
+ 芒果测试平台管理员请注意查收:
+ 触发用户:{request.user.get('username')}
+ 触发时间:{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
+ 错误函数:{func.__name__}
+ 异常类型: {type(error)}
+ 错误提示: {str(error)}
+ 错误详情:{trace}
+ 参数list:{args}
+ 参数dict:{kwargs}
+
+ **********************************
+ 详细情况可前往芒果自动化平台查看,非相关负责人员可忽略此消息。谢谢!
+
+ -----------芒果自动化平台
+ """
+ NoticeMain.mail_send(content)
return ResponseData.fail(ERROR_MSG_0000)
return wrapper
--
Gitee
From c55ac6c3815a1ac18de6dcbcc201e490e14f2113 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=AF=9B=E9=B9=8F?= <729164035@qq.com>
Date: Thu, 1 Aug 2024 16:20:40 +0800
Subject: [PATCH 03/15] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=BA=86=E8=B0=83?=
=?UTF-8?q?=E5=BC=8F=E6=B5=8F=E8=A7=88=E5=99=A8=E7=9A=84bug=E5=92=8C?=
=?UTF-8?q?=E5=BD=95=E5=88=B6bug=EF=BC=9B=E4=BC=98=E5=8C=96=E4=BA=86?=
=?UTF-8?q?=E6=89=A7=E8=A1=8C=E5=99=A8=E5=9B=9E=E8=B0=83=E5=87=BD=E6=95=B0?=
=?UTF-8?q?=E7=9A=84=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
MangoActuator/requirements.txt | 2 +-
.../PyAutoTest/auto_test/auto_ui/views/ui_config.py | 13 +++++++------
MangoServer/PyAutoTest/tools/decorator/retry.py | 3 ++-
MangoServer/PyAutoTest/tools/view/response_msg.py | 1 +
mango-console/src/api/uitest/index.ts | 7 +++++--
mango-console/src/views/apitest/info/index.vue | 2 +-
mango-console/src/views/uitest/equipment/index.vue | 2 +-
7 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/MangoActuator/requirements.txt b/MangoActuator/requirements.txt
index 7e7f7f4d..c8a88c8d 100644
--- a/MangoActuator/requirements.txt
+++ b/MangoActuator/requirements.txt
@@ -26,6 +26,6 @@ blinker==1.7.0
retrying==1.3.4
Pympler==1.0.1
-adbutils==2.4.1
+adbutils==2.7.0
locust==2.27.0
gevent==24.2.1
\ No newline at end of file
diff --git a/MangoServer/PyAutoTest/auto_test/auto_ui/views/ui_config.py b/MangoServer/PyAutoTest/auto_test/auto_ui/views/ui_config.py
index 29d046cc..a124275b 100644
--- a/MangoServer/PyAutoTest/auto_test/auto_ui/views/ui_config.py
+++ b/MangoServer/PyAutoTest/auto_test/auto_ui/views/ui_config.py
@@ -101,16 +101,17 @@ class UiConfigViews(ViewSet):
config_obj = UiConfig.objects.get(user_id=request.user['id'],
status=StatusEnum.SUCCESS.value,
type=DriveTypeEnum.WEB.value)
- if user_obj.selected_environment is not None and user_obj.selected_environment != 0:
+ if user_obj.selected_environment is None:
return ResponseData.fail(RESPONSE_MSG_0058, )
+ if user_obj.selected_project is None:
+ return ResponseData.fail(RESPONSE_MSG_0120, )
- test_object = TestObject.objects.get(id=user_obj.selected_environment)
- project_id = test_object.project_product.project.id
host_list = list(TestObject.objects
.filter(project_product_id__in=ProjectProduct
.objects
- .filter(project_id=project_id,
- client_type=ProductTypeEnum.WEB.value).values_list('id'))
+ .filter(project_id=user_obj.selected_project,
+ client_type=ProductTypeEnum.WEB.value).values_list('id'),
+ environment=user_obj.selected_environment)
.values_list('value', flat=True))
host_list = [urllib.parse.urlparse(url).netloc for url in process_urls(host_list)]
web_config = WEBConfigModel(browser_type=config_obj.browser_type,
@@ -119,7 +120,7 @@ class UiConfigViews(ViewSet):
is_headless=config_obj.is_headless,
device=config_obj.device,
is_header_intercept=True,
- project_product=test_object.project_product_id,
+ project_product=user_obj.selected_project,
host_list=host_list)
else:
config_obj = self.model.objects.get(id=request.query_params.get('id'))
diff --git a/MangoServer/PyAutoTest/tools/decorator/retry.py b/MangoServer/PyAutoTest/tools/decorator/retry.py
index d09ec608..e869bfad 100644
--- a/MangoServer/PyAutoTest/tools/decorator/retry.py
+++ b/MangoServer/PyAutoTest/tools/decorator/retry.py
@@ -18,11 +18,12 @@ def orm_retry(func_name: str, max_retries=5, delay=2):
def decorator(func):
def wrapper(*args, **kwargs):
try_count = 0
- error = None
+ error = ''
while try_count < max_retries:
try:
return func(*args, **kwargs)
except Error as error:
+ error = error
log.error(f'重试失败: 函数:{func_name}, 错误提示:{error}')
close_old_connections()
connection.ensure_connection()
diff --git a/MangoServer/PyAutoTest/tools/view/response_msg.py b/MangoServer/PyAutoTest/tools/view/response_msg.py
index 30169733..74d16f03 100644
--- a/MangoServer/PyAutoTest/tools/view/response_msg.py
+++ b/MangoServer/PyAutoTest/tools/view/response_msg.py
@@ -122,3 +122,4 @@ RESPONSE_MSG_0116 = (300, '内部保存失败,请检查数据:{}')
RESPONSE_MSG_0117 = (300, '内部更新失败,请检查数据:{}')
RESPONSE_MSG_0118 = (200, '获取产品名称成功')
RESPONSE_MSG_0119 = (300, '每个项目的环境和类型,只允许开启一个')
+RESPONSE_MSG_0120 = (300, '请先选择测试环境后再尝试')
diff --git a/mango-console/src/api/uitest/index.ts b/mango-console/src/api/uitest/index.ts
index 4a9e8742..55de19f4 100644
--- a/mango-console/src/api/uitest/index.ts
+++ b/mango-console/src/api/uitest/index.ts
@@ -405,11 +405,14 @@ export function getUiCaseStepsRefreshCacheData(id: number) {
},
})
}
-export function getUiConfigNewBrowserObj(is_recording: number) {
+export function getUiConfigNewBrowserObj(id: number | null, is_recording: number) {
return get({
url: url.uiConfigNewBrowserObj,
data: () => {
- return { is_recording: is_recording }
+ return {
+ id: id,
+ is_recording: is_recording,
+ }
},
})
}
diff --git a/mango-console/src/views/apitest/info/index.vue b/mango-console/src/views/apitest/info/index.vue
index 4de2b0a7..807c3cee 100644
--- a/mango-console/src/views/apitest/info/index.vue
+++ b/mango-console/src/views/apitest/info/index.vue
@@ -432,7 +432,7 @@
cancelText: '取消',
okText: '确定',
onOk: () => {
- getUiConfigNewBrowserObj(1)
+ getUiConfigNewBrowserObj(null, 1)
.then((res) => {
Message.success(res.msg)
})
diff --git a/mango-console/src/views/uitest/equipment/index.vue b/mango-console/src/views/uitest/equipment/index.vue
index d7e94c91..b2e1ffff 100644
--- a/mango-console/src/views/uitest/equipment/index.vue
+++ b/mango-console/src/views/uitest/equipment/index.vue
@@ -407,7 +407,7 @@
}
function onDebugWEB(id: number) {
- getUiConfigNewBrowserObj(id)
+ getUiConfigNewBrowserObj(id, 0)
.then((res) => {
data.driveType = res.data
})
--
Gitee
From 980ac9da60cff31110b7a57e254abfcb31680b38 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=AF=9B=E9=B9=8F?= <729164035@qq.com>
Date: Fri, 2 Aug 2024 09:29:39 +0800
Subject: [PATCH 04/15] =?UTF-8?q?=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
MangoServer/PyAutoTest/settings/dev.py | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/MangoServer/PyAutoTest/settings/dev.py b/MangoServer/PyAutoTest/settings/dev.py
index 38ee2b18..aa177024 100644
--- a/MangoServer/PyAutoTest/settings/dev.py
+++ b/MangoServer/PyAutoTest/settings/dev.py
@@ -9,17 +9,12 @@
IS_SQLITE = False # 是否选用mysql作为数据源
# ************************ Mysql配置 ************************ #
-
-# mysql_db_name = 'mango_server'
-# mysql_user = 'root'
-# mysql_password = 'mP123456&'
-# # mysql_ip = '127.0.0.1'
-# mysql_ip = '121.37.174.56'
mysql_port = 3306
-mysql_db_name = 'auto_test'
+mysql_db_name = 'test'
mysql_user = 'root'
-mysql_password = 'Root@123'
-mysql_ip = '172.16.100.26'
+mysql_password = 'mP123456&'
+mysql_ip = '127.0.0.1'
+
# ************************ DEBUG配置 ************************ #
DEBUG = True
--
Gitee
From dd234ee6540c9f2d280691cc7413c1bd3ac5077a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=AF=9B=E9=B9=8F?= <729164035@qq.com>
Date: Fri, 2 Aug 2024 14:37:25 +0800
Subject: [PATCH 05/15] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AE=9A=E6=97=B6?=
=?UTF-8?q?=E4=BB=BB=E5=8A=A1=E8=B7=9F=E9=9A=8F=E7=9A=84=E6=B5=8B=E8=AF=95?=
=?UTF-8?q?=E7=8E=AF=E5=A2=83=E7=BB=91=E5=AE=9A=EF=BC=88=E8=BF=98=E6=9C=89?=
=?UTF-8?q?=E4=BC=98=E5=8C=96=E7=AD=89=E5=BE=85=E5=90=8E=E7=BB=AD=E5=BC=80?=
=?UTF-8?q?=E5=8F=91=EF=BC=89=EF=BC=9B=E4=BF=AE=E5=A4=8Dapi=E6=8E=A5?=
=?UTF-8?q?=E5=8F=A3=E6=8E=92=E5=BA=8F=E6=8A=A5=E9=94=99=E7=9A=84=E5=BC=82?=
=?UTF-8?q?=E5=B8=B8=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../auto_api/service/api_call/api_case.py | 3 +--
.../service/base_tools/common_base.py | 5 ++---
.../auto_api/service/base_tools/dependence.py | 2 +-
.../auto_api/service/base_tools/http_base.py | 2 +-
.../auto_api/views/api_case_detailed.py | 6 ++---
...remove_scheduledtasks_test_obj_and_more.py | 22 +++++++++++++++++++
.../auto_test/auto_system/models.py | 2 +-
.../auto_system/service/cache_data_value.py | 2 +-
.../auto_system/service/mini_io/mini_io.py | 2 +-
.../service/notic_tools/__init__.py | 2 +-
.../service/notic_tools/mail_send.py | 2 +-
.../service/notic_tools/wechat_send.py | 2 +-
.../service/scheduled_tasks/tasks.py | 17 +++++++-------
.../service/socket_link/socket_user.py | 2 +-
.../auto_ui/service/test_report_writing.py | 2 +-
.../auto_test/auto_ui/service/ui_test_run.py | 12 +++++-----
.../auto_test/auto_user/tools/factory.py | 2 +-
MangoServer/PyAutoTest/exceptions/__init__.py | 2 +-
.../{tools/view => exceptions}/error_msg.py | 3 ++-
.../PyAutoTest/exceptions/user_exception.py | 10 +++++++++
.../tools/base_request/request_tool.py | 2 +-
.../tools/data_processor/__init__.py | 2 +-
.../tools/data_processor/json_tool.py | 2 +-
.../tools/data_processor/random_file.py | 2 +-
.../data_processor/random_string_data.py | 2 +-
.../tools/database/mysql_control.py | 2 +-
.../tools/decorator/error_response.py | 8 +++++--
.../views/timing/scheduled-tasks/config.ts | 10 ++++-----
.../views/timing/scheduled-tasks/index.vue | 19 ++++++++--------
29 files changed, 93 insertions(+), 58 deletions(-)
create mode 100644 MangoServer/PyAutoTest/auto_test/auto_system/migrations/0004_remove_scheduledtasks_test_obj_and_more.py
rename MangoServer/PyAutoTest/{tools/view => exceptions}/error_msg.py (97%)
create mode 100644 MangoServer/PyAutoTest/exceptions/user_exception.py
diff --git a/MangoServer/PyAutoTest/auto_test/auto_api/service/api_call/api_case.py b/MangoServer/PyAutoTest/auto_test/auto_api/service/api_call/api_case.py
index 6a4c8b28..a45f52c5 100644
--- a/MangoServer/PyAutoTest/auto_test/auto_api/service/api_call/api_case.py
+++ b/MangoServer/PyAutoTest/auto_test/auto_api/service/api_call/api_case.py
@@ -20,8 +20,7 @@ from PyAutoTest.exceptions.api_exception import CaseIsEmptyError, UnknownError
from PyAutoTest.exceptions.tools_exception import SyntaxErrorError, MysqlQueryIsNullError
from PyAutoTest.models.apimodel import RequestDataModel, ResponseDataModel
from PyAutoTest.models.socket_model import SocketDataModel
-from PyAutoTest.tools.log_collector import log
-from PyAutoTest.tools.view.error_msg import *
+from PyAutoTest.exceptions.error_msg import *
class ApiCaseRun(CaseMethod, TestResult):
diff --git a/MangoServer/PyAutoTest/auto_test/auto_api/service/base_tools/common_base.py b/MangoServer/PyAutoTest/auto_test/auto_api/service/base_tools/common_base.py
index f30dddf7..361b765e 100644
--- a/MangoServer/PyAutoTest/auto_test/auto_api/service/base_tools/common_base.py
+++ b/MangoServer/PyAutoTest/auto_test/auto_api/service/base_tools/common_base.py
@@ -8,9 +8,8 @@ from urllib.parse import urljoin
from PyAutoTest.auto_test.auto_api.models import ApiPublic, ApiInfo
from PyAutoTest.auto_test.auto_system.models import TestObject
-from PyAutoTest.auto_test.auto_user.tools.factory import func_mysql_config, func_test_object_value
+from PyAutoTest.auto_test.auto_user.tools.factory import func_mysql_config
from PyAutoTest.enums.api_enum import ApiPublicTypeEnum, MethodEnum
-from PyAutoTest.enums.tools_enum import AutoTypeEnum
from PyAutoTest.enums.tools_enum import StatusEnum
from PyAutoTest.exceptions.api_exception import LoginError
from PyAutoTest.exceptions.tools_exception import SyntaxErrorError, MysqlQueryIsNullError
@@ -18,7 +17,7 @@ from PyAutoTest.models.apimodel import RequestDataModel
from PyAutoTest.tools.base_request.request_tool import BaseRequest
from PyAutoTest.tools.data_processor import DataProcessor
from PyAutoTest.tools.database.mysql_control import MysqlConnect
-from PyAutoTest.tools.view.error_msg import ERROR_MSG_0003, ERROR_MSG_0033, ERROR_MSG_0035
+from PyAutoTest.exceptions.error_msg import ERROR_MSG_0003, ERROR_MSG_0033, ERROR_MSG_0035
class CommonBase(DataProcessor):
diff --git a/MangoServer/PyAutoTest/auto_test/auto_api/service/base_tools/dependence.py b/MangoServer/PyAutoTest/auto_test/auto_api/service/base_tools/dependence.py
index 685ad816..83730d80 100644
--- a/MangoServer/PyAutoTest/auto_test/auto_api/service/base_tools/dependence.py
+++ b/MangoServer/PyAutoTest/auto_test/auto_api/service/base_tools/dependence.py
@@ -16,7 +16,7 @@ from PyAutoTest.exceptions.tools_exception import CacheIsEmptyError
from PyAutoTest.models.apimodel import RequestDataModel, ResponseDataModel
from PyAutoTest.tools.assertion.public_assertion import PublicAssertion
from PyAutoTest.tools.base_request.request_tool import BaseRequest
-from PyAutoTest.tools.view.error_msg import *
+from PyAutoTest.exceptions.error_msg import *
log = logging.getLogger('api')
diff --git a/MangoServer/PyAutoTest/auto_test/auto_api/service/base_tools/http_base.py b/MangoServer/PyAutoTest/auto_test/auto_api/service/base_tools/http_base.py
index c4834331..2576294a 100644
--- a/MangoServer/PyAutoTest/auto_test/auto_api/service/base_tools/http_base.py
+++ b/MangoServer/PyAutoTest/auto_test/auto_api/service/base_tools/http_base.py
@@ -14,7 +14,7 @@ from PyAutoTest.auto_test.auto_system.service.cache_data_value import CacheDataV
from PyAutoTest.enums.system_enum import CacheDataKeyEnum
from PyAutoTest.exceptions.api_exception import AgentError, UnknownError
from PyAutoTest.models.apimodel import RequestDataModel, ResponseDataModel
-from PyAutoTest.tools.view.error_msg import *
+from PyAutoTest.exceptions.error_msg import *
log = logging.getLogger('api')
diff --git a/MangoServer/PyAutoTest/auto_test/auto_api/views/api_case_detailed.py b/MangoServer/PyAutoTest/auto_test/auto_api/views/api_case_detailed.py
index f4846ed4..06cbf48f 100644
--- a/MangoServer/PyAutoTest/auto_test/auto_api/views/api_case_detailed.py
+++ b/MangoServer/PyAutoTest/auto_test/auto_api/views/api_case_detailed.py
@@ -100,8 +100,7 @@ class ApiCaseDetailedCRUD(ModelCRUD):
@return:
"""
data = {'id': _id, 'case_flow': '', 'name': ''}
- case_id = self.model.objects.get(id=_id).case.id
- run = self.model.objects.filter(case=case_id).order_by('case_sort')
+ run = self.model.objects.filter(case=_id).order_by('case_sort')
for i in run:
data['case_flow'] += '->'
if i.api_info:
@@ -109,7 +108,7 @@ class ApiCaseDetailedCRUD(ModelCRUD):
data['name'] = run[0].case.name
from PyAutoTest.auto_test.auto_api.views.api_case import ApiCaseCRUD
api_case = ApiCaseCRUD()
- res = api_case.serializer(instance=ApiCase.objects.get(id=case_id), data=data)
+ res = api_case.serializer(instance=ApiCase.objects.get(id=_id), data=data)
if res.is_valid():
res.save()
else:
@@ -134,6 +133,7 @@ class ApiCaseDetailedViews(ViewSet):
obj.case_sort = i['case_sort']
case_id = obj.case.id
obj.save()
+ print(case_id)
ApiCaseDetailedCRUD().callback(case_id)
return ResponseData.success(RESPONSE_MSG_0013, )
diff --git a/MangoServer/PyAutoTest/auto_test/auto_system/migrations/0004_remove_scheduledtasks_test_obj_and_more.py b/MangoServer/PyAutoTest/auto_test/auto_system/migrations/0004_remove_scheduledtasks_test_obj_and_more.py
new file mode 100644
index 00000000..c2f0d16e
--- /dev/null
+++ b/MangoServer/PyAutoTest/auto_test/auto_system/migrations/0004_remove_scheduledtasks_test_obj_and_more.py
@@ -0,0 +1,22 @@
+# Generated by Django 4.1.5 on 2024-08-02 09:38
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('auto_system', '0003_remove_testsuitereport_test_object_and_more'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='scheduledtasks',
+ name='test_obj',
+ ),
+ migrations.AddField(
+ model_name='scheduledtasks',
+ name='test_env',
+ field=models.SmallIntegerField(null=True, verbose_name='测试环境'),
+ ),
+ ]
diff --git a/MangoServer/PyAutoTest/auto_test/auto_system/models.py b/MangoServer/PyAutoTest/auto_test/auto_system/models.py
index 8be02c35..c3af8638 100644
--- a/MangoServer/PyAutoTest/auto_test/auto_system/models.py
+++ b/MangoServer/PyAutoTest/auto_test/auto_system/models.py
@@ -83,7 +83,7 @@ class TestSuiteReport(models.Model):
class ScheduledTasks(models.Model):
create_time = models.DateTimeField(verbose_name="创建时间", auto_now_add=True)
update_time = models.DateTimeField(verbose_name="修改时间", auto_now=True)
- test_obj = models.ForeignKey(to=TestObject, to_field="id", on_delete=models.SET_NULL, null=True)
+ test_env = models.SmallIntegerField(verbose_name="测试环境", null=True)
name = models.CharField(verbose_name="任务名称", max_length=64)
case_people = models.ForeignKey(to=User, to_field="id", verbose_name='用例责任人', on_delete=models.SET_NULL, null=True)
case_executor = models.JSONField(verbose_name='用例执行人', null=True)
diff --git a/MangoServer/PyAutoTest/auto_test/auto_system/service/cache_data_value.py b/MangoServer/PyAutoTest/auto_test/auto_system/service/cache_data_value.py
index e2790977..5f23586a 100644
--- a/MangoServer/PyAutoTest/auto_test/auto_system/service/cache_data_value.py
+++ b/MangoServer/PyAutoTest/auto_test/auto_system/service/cache_data_value.py
@@ -8,7 +8,7 @@ import json
from PyAutoTest.auto_test.auto_system.models import CacheData
from PyAutoTest.enums.system_enum import CacheValueTypeEnum
from PyAutoTest.exceptions.tools_exception import CacheKetNullError
-from PyAutoTest.tools.view.error_msg import ERROR_MSG_0038
+from PyAutoTest.exceptions.error_msg import ERROR_MSG_0038
class CacheDataValue:
diff --git a/MangoServer/PyAutoTest/auto_test/auto_system/service/mini_io/mini_io.py b/MangoServer/PyAutoTest/auto_test/auto_system/service/mini_io/mini_io.py
index 0d2525fa..82ae1143 100644
--- a/MangoServer/PyAutoTest/auto_test/auto_system/service/mini_io/mini_io.py
+++ b/MangoServer/PyAutoTest/auto_test/auto_system/service/mini_io/mini_io.py
@@ -12,7 +12,7 @@ from minio.error import S3Error
from urllib3.exceptions import MaxRetryError
from PyAutoTest.exceptions.tools_exception import MiniIoConnError, MiniIoFileError
-from PyAutoTest.tools.view.error_msg import ERROR_MSG_0042, ERROR_MSG_0043, ERROR_MSG_0044, ERROR_MSG_0045
+from PyAutoTest.exceptions.error_msg import ERROR_MSG_0042, ERROR_MSG_0043, ERROR_MSG_0044, ERROR_MSG_0045
class MiniIo:
diff --git a/MangoServer/PyAutoTest/auto_test/auto_system/service/notic_tools/__init__.py b/MangoServer/PyAutoTest/auto_test/auto_system/service/notic_tools/__init__.py
index 98f49693..498c8aad 100644
--- a/MangoServer/PyAutoTest/auto_test/auto_system/service/notic_tools/__init__.py
+++ b/MangoServer/PyAutoTest/auto_test/auto_system/service/notic_tools/__init__.py
@@ -19,7 +19,7 @@ from PyAutoTest.enums.system_enum import NoticeEnum
from PyAutoTest.enums.tools_enum import StatusEnum, ClientNameEnum
from PyAutoTest.exceptions.tools_exception import JsonSerializeError, CacheKetNullError, UserEmailIsNullError
from PyAutoTest.models.tools_model import TestReportModel, EmailNoticeModel, WeChatNoticeModel
-from PyAutoTest.tools.view.error_msg import ERROR_MSG_0012, ERROR_MSG_0031, ERROR_MSG_0048
+from PyAutoTest.exceptions.error_msg import ERROR_MSG_0012, ERROR_MSG_0031, ERROR_MSG_0048
log = logging.getLogger('system')
diff --git a/MangoServer/PyAutoTest/auto_test/auto_system/service/notic_tools/mail_send.py b/MangoServer/PyAutoTest/auto_test/auto_system/service/notic_tools/mail_send.py
index 21ec7c20..427dfd28 100644
--- a/MangoServer/PyAutoTest/auto_test/auto_system/service/notic_tools/mail_send.py
+++ b/MangoServer/PyAutoTest/auto_test/auto_system/service/notic_tools/mail_send.py
@@ -14,7 +14,7 @@ from PyAutoTest.enums.system_enum import CacheDataKeyEnum
from PyAutoTest.enums.tools_enum import ClientNameEnum
from PyAutoTest.exceptions.tools_exception import SendMessageError
from PyAutoTest.models.tools_model import TestReportModel, EmailNoticeModel
-from PyAutoTest.tools.view.error_msg import ERROR_MSG_0016, ERROR_MSG_0017
+from PyAutoTest.exceptions.error_msg import ERROR_MSG_0016, ERROR_MSG_0017
log = logging.getLogger('system')
diff --git a/MangoServer/PyAutoTest/auto_test/auto_system/service/notic_tools/wechat_send.py b/MangoServer/PyAutoTest/auto_test/auto_system/service/notic_tools/wechat_send.py
index 21f4f74e..7818755a 100644
--- a/MangoServer/PyAutoTest/auto_test/auto_system/service/notic_tools/wechat_send.py
+++ b/MangoServer/PyAutoTest/auto_test/auto_system/service/notic_tools/wechat_send.py
@@ -12,7 +12,7 @@ from PyAutoTest.enums.system_enum import CacheDataKeyEnum
from PyAutoTest.enums.tools_enum import ClientNameEnum
from PyAutoTest.exceptions.tools_exception import SendMessageError, ValueTypeError
from PyAutoTest.models.tools_model import TestReportModel, WeChatNoticeModel
-from PyAutoTest.tools.view.error_msg import ERROR_MSG_0013, ERROR_MSG_0014, ERROR_MSG_0018, ERROR_MSG_0019, \
+from PyAutoTest.exceptions.error_msg import ERROR_MSG_0013, ERROR_MSG_0014, ERROR_MSG_0018, ERROR_MSG_0019, \
ERROR_MSG_0020
log = logging.getLogger('system')
diff --git a/MangoServer/PyAutoTest/auto_test/auto_system/service/scheduled_tasks/tasks.py b/MangoServer/PyAutoTest/auto_test/auto_system/service/scheduled_tasks/tasks.py
index c6c18c2e..c4ee0433 100644
--- a/MangoServer/PyAutoTest/auto_test/auto_system/service/scheduled_tasks/tasks.py
+++ b/MangoServer/PyAutoTest/auto_test/auto_system/service/scheduled_tasks/tasks.py
@@ -54,14 +54,14 @@ class Tasks:
if scheduled_tasks.type == AutoTestTypeEnum.API.value:
cls.api_task(
scheduled_tasks_id=scheduled_tasks.id,
- test_obj_id=scheduled_tasks.test_obj.id,
+ test_env=scheduled_tasks.test_env,
is_notice=scheduled_tasks.is_notice,
user_obj={'id': scheduled_tasks.case_people.id, 'username': scheduled_tasks.case_people.username},
is_trigger=True)
elif scheduled_tasks.type == AutoTestTypeEnum.UI.value:
cls.ui_task(scheduled_tasks.id,
scheduled_tasks.case_people.id,
- scheduled_tasks.test_obj.id,
+ scheduled_tasks.test_env,
scheduled_tasks.is_notice,
scheduled_tasks.case_executor,
True)
@@ -75,7 +75,7 @@ class Tasks:
task = Thread(
target=cls.api_task,
args=(scheduled_tasks.id,
- scheduled_tasks.test_obj.id,
+ scheduled_tasks.test_env,
scheduled_tasks.is_notice,
{'id': scheduled_tasks.case_people.id, 'username': scheduled_tasks.case_people.username}
)
@@ -97,7 +97,7 @@ class Tasks:
@orm_retry('api_task')
def api_task(cls,
scheduled_tasks_id: int,
- test_obj_id: int,
+ test_env: int,
is_notice: int,
user_obj: dict,
is_trigger: bool = False):
@@ -108,7 +108,7 @@ class Tasks:
if case_id_list:
log.info(f'定时任务开始执行API用例,包含用例ID:{case_id_list}')
- ApiCaseRun(test_obj_id=test_obj_id, is_notice=is_notice, user_obj=user_obj).case_batch(
+ ApiCaseRun(test_env, is_notice=is_notice, user_obj=user_obj).case_batch(
case_id_list)
except MangoServerError as error:
log.error(f'执行API定时任务失败,错误消息:{error.msg}')
@@ -120,7 +120,7 @@ class Tasks:
def ui_task(cls,
scheduled_tasks_id: int,
user_id: int,
- test_obj_id: int,
+ test_env: int,
is_notice: int,
case_executor: list,
is_trigger: bool = False,
@@ -133,11 +133,10 @@ class Tasks:
log.info(f'定时任务开始执行UI用例,包含用例ID:{case_id_list}')
UiTestRun(
user_id=user_id,
- test_obj_id=test_obj_id,
+ test_env=test_env,
+ case_executor=case_executor,
tasks_id=scheduled_tasks_id,
is_notice=is_notice,
- spare_test_object_id=test_obj_id,
- case_executor=case_executor
).case_batch(case_id_list)
except MangoServerError as error:
log.error(f'执行UI定时任务失败,错误消息:{error.msg}')
diff --git a/MangoServer/PyAutoTest/auto_test/auto_system/service/socket_link/socket_user.py b/MangoServer/PyAutoTest/auto_test/auto_system/service/socket_link/socket_user.py
index b9241f6e..0126aac9 100644
--- a/MangoServer/PyAutoTest/auto_test/auto_system/service/socket_link/socket_user.py
+++ b/MangoServer/PyAutoTest/auto_test/auto_system/service/socket_link/socket_user.py
@@ -9,7 +9,7 @@ from pydantic import BaseModel
from PyAutoTest.enums.tools_enum import ClientNameEnum
from PyAutoTest.exceptions.tools_exception import SocketClientNotPresentError
-from PyAutoTest.tools.view.error_msg import ERROR_MSG_0028
+from PyAutoTest.exceptions.error_msg import ERROR_MSG_0028
class SocketUserModel(BaseModel):
diff --git a/MangoServer/PyAutoTest/auto_test/auto_ui/service/test_report_writing.py b/MangoServer/PyAutoTest/auto_test/auto_ui/service/test_report_writing.py
index 35a58a22..a695c2af 100644
--- a/MangoServer/PyAutoTest/auto_test/auto_ui/service/test_report_writing.py
+++ b/MangoServer/PyAutoTest/auto_test/auto_ui/service/test_report_writing.py
@@ -19,7 +19,7 @@ from PyAutoTest.exceptions.tools_exception import DoesNotExistError
from PyAutoTest.models.socket_model import SocketDataModel
from PyAutoTest.models.socket_model.ui_model import CaseResultModel, PageStepsResultModel
from PyAutoTest.tools.decorator.retry import orm_retry
-from PyAutoTest.tools.view.error_msg import ERROR_MSG_0030
+from PyAutoTest.exceptions.error_msg import ERROR_MSG_0030
log = logging.getLogger('ui')
diff --git a/MangoServer/PyAutoTest/auto_test/auto_ui/service/ui_test_run.py b/MangoServer/PyAutoTest/auto_test/auto_ui/service/ui_test_run.py
index c8278929..b97fbb1c 100644
--- a/MangoServer/PyAutoTest/auto_test/auto_ui/service/ui_test_run.py
+++ b/MangoServer/PyAutoTest/auto_test/auto_ui/service/ui_test_run.py
@@ -17,9 +17,10 @@ from PyAutoTest.enums.ui_enum import DriveTypeEnum
from PyAutoTest.exceptions import MangoServerError
from PyAutoTest.exceptions.tools_exception import DoesNotExistError, SocketClientNotPresentError
from PyAutoTest.exceptions.ui_exception import UiConfigQueryIsNoneError
+from PyAutoTest.exceptions.user_exception import UserIsNoneError
from PyAutoTest.models.socket_model import SocketDataModel, QueueModel
from PyAutoTest.models.socket_model.ui_model import *
-from PyAutoTest.tools.view.error_msg import ERROR_MSG_0029, ERROR_MSG_0030
+from PyAutoTest.exceptions.error_msg import ERROR_MSG_0029, ERROR_MSG_0030, ERROR_MSG_0050
from PyAutoTest.tools.view.snowflake import Snowflake
@@ -31,19 +32,20 @@ class UiTestRun:
case_executor: list | None = None,
tasks_id: int = None,
is_notice: int = 0,
- spare_test_object_id: int = None,
):
- self.user_obj = User.objects.get(id=user_id)
self.user_id = user_id
+ self.username = User.objects.get(id=user_id).username
self.test_env = test_env
self.tasks_id = tasks_id
self.is_notice = is_notice
- self.spare_test_object_id = spare_test_object_id
self.case_executor = case_executor
if self.case_executor:
username_list = []
for nickname in self.case_executor:
- user_obj = User.objects.get(nickname=nickname)
+ try:
+ user_obj = User.objects.get(nickname=nickname)
+ except User.DoesNotExist:
+ raise UserIsNoneError(*ERROR_MSG_0050)
try:
SocketUser.get_user_client_obj(user_obj.username)
except SocketClientNotPresentError as error:
diff --git a/MangoServer/PyAutoTest/auto_test/auto_user/tools/factory.py b/MangoServer/PyAutoTest/auto_test/auto_user/tools/factory.py
index 02eb1923..dbf33c60 100644
--- a/MangoServer/PyAutoTest/auto_test/auto_user/tools/factory.py
+++ b/MangoServer/PyAutoTest/auto_test/auto_user/tools/factory.py
@@ -9,7 +9,7 @@ from PyAutoTest.auto_test.auto_system.models import Database, TestObject
from PyAutoTest.enums.tools_enum import AutoTypeEnum
from PyAutoTest.exceptions.tools_exception import DoesNotExistError, MysqlConfigError, TestObjectNullError
from PyAutoTest.models.tools_model import MysqlConingModel
-from PyAutoTest.tools.view.error_msg import ERROR_MSG_0021, ERROR_MSG_0022, ERROR_MSG_0046, ERROR_MSG_0049
+from PyAutoTest.exceptions.error_msg import ERROR_MSG_0021, ERROR_MSG_0022, ERROR_MSG_0046, ERROR_MSG_0049
def func_mysql_config(env: int, project_product_id: int) -> MysqlConingModel:
diff --git a/MangoServer/PyAutoTest/exceptions/__init__.py b/MangoServer/PyAutoTest/exceptions/__init__.py
index 49f74c7d..005a02f1 100644
--- a/MangoServer/PyAutoTest/exceptions/__init__.py
+++ b/MangoServer/PyAutoTest/exceptions/__init__.py
@@ -5,7 +5,7 @@
# @Author : 毛鹏
import logging
-from PyAutoTest.tools.view.error_msg import ERROR_MSG_0011
+from PyAutoTest.exceptions.error_msg import ERROR_MSG_0011
log = logging.getLogger('system')
diff --git a/MangoServer/PyAutoTest/tools/view/error_msg.py b/MangoServer/PyAutoTest/exceptions/error_msg.py
similarity index 97%
rename from MangoServer/PyAutoTest/tools/view/error_msg.py
rename to MangoServer/PyAutoTest/exceptions/error_msg.py
index 0b6c36ac..57f89cf7 100644
--- a/MangoServer/PyAutoTest/tools/view/error_msg.py
+++ b/MangoServer/PyAutoTest/exceptions/error_msg.py
@@ -51,4 +51,5 @@ ERROR_MSG_0045 = (345, '需要上传的文件路径不正确')
ERROR_MSG_0046 = (346, '您需要执行的用例没有对应的测试环境')
ERROR_MSG_0047 = (347, '方法不存在,请检查输入的方法名称是否正确')
ERROR_MSG_0048 = (348, '用户邮箱是空,请先给用户设置邮箱之后,再使用')
-ERROR_MSG_0049 = (348, '你的测试项目有重复的测试环境,请检查数据,重复的部署环境和产品和自动化类型只允许存在一个')
+ERROR_MSG_0049 = (349, '你的测试项目有重复的测试环境,请检查数据,重复的部署环境和产品和自动化类型只允许存在一个')
+ERROR_MSG_0050 = (350, '用户查询结果为空')
diff --git a/MangoServer/PyAutoTest/exceptions/user_exception.py b/MangoServer/PyAutoTest/exceptions/user_exception.py
new file mode 100644
index 00000000..0c479797
--- /dev/null
+++ b/MangoServer/PyAutoTest/exceptions/user_exception.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# @Project: MangoActuator
+# @Description:
+# @Time : 2023-07-07 10:14
+# @Author : 毛鹏
+from PyAutoTest.exceptions import MangoServerError
+
+
+class UserIsNoneError(MangoServerError):
+ pass
diff --git a/MangoServer/PyAutoTest/tools/base_request/request_tool.py b/MangoServer/PyAutoTest/tools/base_request/request_tool.py
index 42246599..7eb686bb 100644
--- a/MangoServer/PyAutoTest/tools/base_request/request_tool.py
+++ b/MangoServer/PyAutoTest/tools/base_request/request_tool.py
@@ -15,7 +15,7 @@ from PyAutoTest.enums.system_enum import CacheDataKeyEnum
from PyAutoTest.exceptions.api_exception import AgentError, UnknownError
from PyAutoTest.models.apimodel import RequestDataModel, ResponseDataModel
from PyAutoTest.tools.log_collector import log
-from PyAutoTest.tools.view.error_msg import *
+from PyAutoTest.exceptions.error_msg import *
class BaseRequest:
diff --git a/MangoServer/PyAutoTest/tools/data_processor/__init__.py b/MangoServer/PyAutoTest/tools/data_processor/__init__.py
index 7167234e..f3cfcc7a 100644
--- a/MangoServer/PyAutoTest/tools/data_processor/__init__.py
+++ b/MangoServer/PyAutoTest/tools/data_processor/__init__.py
@@ -7,7 +7,7 @@ import json
import re
from PyAutoTest.exceptions.tools_exception import CacheIsEmptyError, MethodDoesNotExistError
-from PyAutoTest.tools.view.error_msg import ERROR_MSG_0027, ERROR_MSG_0047
+from PyAutoTest.exceptions.error_msg import ERROR_MSG_0027, ERROR_MSG_0047
from ..data_processor.cache_tool import CacheTool
from ..data_processor.coding_tool import CodingTool
from ..data_processor.encryption_tool import EncryptionTool
diff --git a/MangoServer/PyAutoTest/tools/data_processor/json_tool.py b/MangoServer/PyAutoTest/tools/data_processor/json_tool.py
index f1f12c51..e78c80cb 100644
--- a/MangoServer/PyAutoTest/tools/data_processor/json_tool.py
+++ b/MangoServer/PyAutoTest/tools/data_processor/json_tool.py
@@ -8,7 +8,7 @@ import json
import jsonpath
from PyAutoTest.exceptions.tools_exception import JsonPathError
-from PyAutoTest.tools.view.error_msg import ERROR_MSG_0011
+from PyAutoTest.exceptions.error_msg import ERROR_MSG_0011
class JsonTool:
diff --git a/MangoServer/PyAutoTest/tools/data_processor/random_file.py b/MangoServer/PyAutoTest/tools/data_processor/random_file.py
index 41a7eda4..d70b6070 100644
--- a/MangoServer/PyAutoTest/tools/data_processor/random_file.py
+++ b/MangoServer/PyAutoTest/tools/data_processor/random_file.py
@@ -5,7 +5,7 @@
# @Author : 毛鹏
from PyAutoTest.exceptions.tools_exception import FileDoesNotEexistError
-from PyAutoTest.tools.view.error_msg import ERROR_MSG_0026
+from PyAutoTest.exceptions.error_msg import ERROR_MSG_0026
class RandomFileData:
diff --git a/MangoServer/PyAutoTest/tools/data_processor/random_string_data.py b/MangoServer/PyAutoTest/tools/data_processor/random_string_data.py
index 777199d4..9cd2888e 100644
--- a/MangoServer/PyAutoTest/tools/data_processor/random_string_data.py
+++ b/MangoServer/PyAutoTest/tools/data_processor/random_string_data.py
@@ -10,7 +10,7 @@ import uuid
from faker import Faker
from PyAutoTest.exceptions.tools_exception import ValueTypeError
-from PyAutoTest.tools.view.error_msg import ERROR_MSG_0015
+from PyAutoTest.exceptions.error_msg import ERROR_MSG_0015
class RandomStringData:
diff --git a/MangoServer/PyAutoTest/tools/database/mysql_control.py b/MangoServer/PyAutoTest/tools/database/mysql_control.py
index 4b06b2cc..66aa3fd1 100644
--- a/MangoServer/PyAutoTest/tools/database/mysql_control.py
+++ b/MangoServer/PyAutoTest/tools/database/mysql_control.py
@@ -10,7 +10,7 @@ from pymysql.err import InternalError, OperationalError, ProgrammingError
from PyAutoTest.exceptions.tools_exception import MySQLConnectionFailureError, MysqlConnectionError, \
MysqlQueryError
from PyAutoTest.models.tools_model import MysqlConingModel
-from PyAutoTest.tools.view.error_msg import ERROR_MSG_0023, ERROR_MSG_0024, ERROR_MSG_0025, ERROR_MSG_0009
+from PyAutoTest.exceptions.error_msg import ERROR_MSG_0023, ERROR_MSG_0024, ERROR_MSG_0025, ERROR_MSG_0009
log = logging.getLogger('system')
diff --git a/MangoServer/PyAutoTest/tools/decorator/error_response.py b/MangoServer/PyAutoTest/tools/decorator/error_response.py
index 2d2f675f..651ffa0c 100644
--- a/MangoServer/PyAutoTest/tools/decorator/error_response.py
+++ b/MangoServer/PyAutoTest/tools/decorator/error_response.py
@@ -11,7 +11,7 @@ from rest_framework.request import Request
from PyAutoTest.auto_test.auto_system.service.notic_tools import NoticeMain
from PyAutoTest.exceptions import MangoServerError
from PyAutoTest.tools.log_collector import log
-from PyAutoTest.tools.view.error_msg import ERROR_MSG_0000
+from PyAutoTest.exceptions.error_msg import ERROR_MSG_0000
from PyAutoTest.tools.view.response_data import ResponseData
log_dict = {
@@ -36,11 +36,15 @@ def error_response(app: str):
return ResponseData.fail((error.code, error.msg))
except Exception as error:
+ try:
+ username = request.user.get('username')
+ except AttributeError:
+ username = None
trace = traceback.format_exc()
log_dict.get(app, log.system).error(f'错误内容:{error}-错误详情:{trace}')
content = f"""
芒果测试平台管理员请注意查收:
- 触发用户:{request.user.get('username')}
+ 触发用户:{username}
触发时间:{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
错误函数:{func.__name__}
异常类型: {type(error)}
diff --git a/mango-console/src/views/timing/scheduled-tasks/config.ts b/mango-console/src/views/timing/scheduled-tasks/config.ts
index bb09f1c7..38e1d40d 100644
--- a/mango-console/src/views/timing/scheduled-tasks/config.ts
+++ b/mango-console/src/views/timing/scheduled-tasks/config.ts
@@ -82,13 +82,13 @@ export const formItems: FormItem[] = reactive([
},
{
label: '测试环境',
- key: 'test_obj',
+ key: 'test_env',
value: '',
placeholder: '请选择执行环境',
required: true,
- type: 'cascader',
+ type: 'select',
validator: function () {
- if (!this.value && this.value !== '0') {
+ if (!this.value && this.value !== 0) {
Message.error(this.placeholder || '')
return false
}
@@ -151,8 +151,8 @@ export const tableColumns = useTableColumn([
},
{
title: '测试环境',
- key: 'test_obj',
- dataIndex: 'test_obj',
+ key: 'test_env',
+ dataIndex: 'test_env',
align: 'left',
},
{
diff --git a/mango-console/src/views/timing/scheduled-tasks/index.vue b/mango-console/src/views/timing/scheduled-tasks/index.vue
index 9bfa22a4..87b31b73 100644
--- a/mango-console/src/views/timing/scheduled-tasks/index.vue
+++ b/mango-console/src/views/timing/scheduled-tasks/index.vue
@@ -87,12 +87,10 @@
{{ record.case_people?.nickname }}
-
- {{
- record.test_obj?.project_product?.project?.name +
- '/' +
- uEnvironment.data[record.test_obj?.environment].title
- }}
+
+
+ {{ uEnvironment.data[record.test_env].title }}
{{ record.case_executor }}
@@ -175,14 +173,15 @@
/>
-
-
+
--
Gitee
From 7f7a886e0bd78b6136a6c0ee0b34190c0b5cf144 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=AF=9B=E9=B9=8F?= <729164035@qq.com>
Date: Fri, 2 Aug 2024 14:57:40 +0800
Subject: [PATCH 06/15] =?UTF-8?q?=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
mango-console/src/views/timing/scheduled-tasks/index.vue | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/mango-console/src/views/timing/scheduled-tasks/index.vue b/mango-console/src/views/timing/scheduled-tasks/index.vue
index 87b31b73..76483510 100644
--- a/mango-console/src/views/timing/scheduled-tasks/index.vue
+++ b/mango-console/src/views/timing/scheduled-tasks/index.vue
@@ -89,7 +89,9 @@
- {{ uEnvironment.data[record.test_env].title }}
--
Gitee
From 0ea7d4e65488484a4b7eef3ddefd45a861e06d0a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=AF=9B=E9=B9=8F?= <729164035@qq.com>
Date: Fri, 2 Aug 2024 15:38:05 +0800
Subject: [PATCH 07/15] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AA?=
=?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E7=9A=84?=
=?UTF-8?q?=E6=8A=A5=E9=94=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
MangoServer/PyAutoTest/auto_test/auto_ui/service/ui_test_run.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/MangoServer/PyAutoTest/auto_test/auto_ui/service/ui_test_run.py b/MangoServer/PyAutoTest/auto_test/auto_ui/service/ui_test_run.py
index b97fbb1c..c0d9551a 100644
--- a/MangoServer/PyAutoTest/auto_test/auto_ui/service/ui_test_run.py
+++ b/MangoServer/PyAutoTest/auto_test/auto_ui/service/ui_test_run.py
@@ -168,7 +168,7 @@ class UiTestRun:
ChatConsumer.active_send(SocketDataModel(
code=200,
msg=f'{ClientNameEnum.DRIVER.value}:收到用例数据,准备开始执行自动化任务!',
- user=username if username else self.user_obj.username,
+ user=username if username else self.username,
is_notice=ClientTypeEnum.ACTUATOR.value,
data=data,
))
--
Gitee
From 15b507b57bc44ff5569625e5070c7566edbcb410 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=AF=9B=E9=B9=8F?= <729164035@qq.com>
Date: Fri, 2 Aug 2024 15:54:00 +0800
Subject: [PATCH 08/15] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=80=E4=B8=AA?=
=?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=85=B3=E9=97=AD=E6=B5=8F=E8=A7=88=E5=99=A8?=
=?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
MangoActuator/autotest/ui/service/page_steps.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/MangoActuator/autotest/ui/service/page_steps.py b/MangoActuator/autotest/ui/service/page_steps.py
index 49e6faf5..389e387e 100644
--- a/MangoActuator/autotest/ui/service/page_steps.py
+++ b/MangoActuator/autotest/ui/service/page_steps.py
@@ -38,8 +38,10 @@ class PageSteps(StepElements):
await self.steps_main()
except MangoActuatorError as error:
if error.code == 310:
- await self.context.close()
- await self.page.close()
+ if self.context:
+ await self.context.close()
+ if self.page:
+ await self.page.close()
self.context = None
self.page = None
await ClientWebSocket().async_send(
--
Gitee
From e316b24c05a0a981b1c84e4fca5785dad71e5972 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=AF=9B=E9=B9=8F?= <729164035@qq.com>
Date: Fri, 2 Aug 2024 17:08:02 +0800
Subject: [PATCH 09/15] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=80=E4=B8=AA?=
=?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=85=B3=E9=97=AD=E6=B5=8F=E8=A7=88=E5=99=A8?=
=?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../autotest/ui/base_tools/web/assertion.py | 88 +++++-----
.../auto_test/auto_ui/service/ui_test_run.py | 4 +-
.../views/uitest/page-steps/details/config.ts | 106 ++++++++++++
.../views/uitest/page-steps/details/index.vue | 110 +-----------
.../src/views/uitest/page/elements/config.ts | 68 ++------
.../src/views/uitest/page/elements/index.vue | 162 +++++++++++-------
6 files changed, 278 insertions(+), 260 deletions(-)
diff --git a/MangoActuator/autotest/ui/base_tools/web/assertion.py b/MangoActuator/autotest/ui/base_tools/web/assertion.py
index 1d531d6d..8cee65cc 100644
--- a/MangoActuator/autotest/ui/base_tools/web/assertion.py
+++ b/MangoActuator/autotest/ui/base_tools/web/assertion.py
@@ -4,7 +4,7 @@
# @Time : 2023-04-26 22:25
# @Author : 毛鹏
-from playwright.async_api import Locator, expect
+from playwright.async_api import Locator, expect as exp
from exceptions.ui_exception import ElementIsEmptyError
from tools.message.error_msg import ERROR_MSG_0021
@@ -16,42 +16,42 @@ class PlaywrightAssertion:
@staticmethod
async def w_not_to_be_empty(actual: Locator):
"""元素不为空"""
- await expect(actual).not_to_be_empty()
+ await exp(actual).not_to_be_empty()
@staticmethod
async def w_not_to_be_enabled(actual: Locator):
"""元素不启用"""
- await expect(actual).not_to_be_enabled()
+ await exp(actual).not_to_be_enabled()
@staticmethod
async def w_not_to_be_focused(actual: Locator):
"""元素不聚焦"""
- await expect(actual).not_to_be_focused()
+ await exp(actual).not_to_be_focused()
@staticmethod
async def w_not_to_be_hidden(actual: Locator):
"""元素不可隐藏"""
- await expect(actual).not_to_be_hidden()
+ await exp(actual).not_to_be_hidden()
@staticmethod
async def w_not_to_be_in_viewport(actual: Locator):
"""元素不在视窗中"""
- await expect(actual).not_to_be_in_viewport()
+ await exp(actual).not_to_be_in_viewport()
@staticmethod
async def w_not_to_be_visible(actual: Locator):
"""元素不可见"""
- await expect(actual).not_to_be_visible()
+ await exp(actual).not_to_be_visible()
@staticmethod
async def w_not_to_contain_text(actual: Locator, expect: str):
"""元素不包含文本"""
- await expect(actual).not_to_contain_text(expect)
+ await exp(actual).not_to_contain_text(expect)
@staticmethod
async def w_not_to_have_class(actual: Locator, expect: str):
"""元素没有阶级"""
- await expect(actual).not_to_have_class(expect)
+ await exp(actual).not_to_have_class(expect)
@staticmethod
async def w_to_have_count(actual: Locator, expect: str):
@@ -60,7 +60,7 @@ class PlaywrightAssertion:
assert int(expect) == 0
if expect is None:
expect = 0
- await expect(actual).to_have_count(int(expect))
+ await exp(actual).to_have_count(int(expect))
@staticmethod
async def w_to_element_count(actual: Locator, count: int):
@@ -69,7 +69,7 @@ class PlaywrightAssertion:
assert actual is None
else:
if actual:
- await expect(actual).to_have_count(int(count))
+ await exp(actual).to_have_count(int(count))
else:
raise ElementIsEmptyError(*ERROR_MSG_0021)
@@ -78,7 +78,7 @@ class PlaywrightAssertion:
"""元素是存在"""
if actual is None:
assert False
- await expect(actual).to_have_count(1)
+ await exp(actual).to_have_count(1)
@staticmethod
async def w_to_element_not_exists(actual: Locator):
@@ -88,17 +88,17 @@ class PlaywrightAssertion:
@staticmethod
async def w_to_be_checked(actual: Locator):
"""复选框已选中"""
- await expect(actual).to_be_checked()
+ await exp(actual).to_be_checked()
@staticmethod
async def w_to_be_disabled(actual: Locator):
"""元素已禁用"""
- await expect(actual).to_be_disabled()
+ await exp(actual).to_be_disabled()
@staticmethod
async def w_not_to_be_editable(actual: Locator):
"""元素已启用"""
- await expect(actual).to_be_editable()
+ await exp(actual).to_be_editable()
@staticmethod
async def w_to_be_empty(actual: Locator | list | None):
@@ -108,130 +108,130 @@ class PlaywrightAssertion:
elif not actual:
assert True
else:
- await expect(actual).to_be_empty()
+ await exp(actual).to_be_empty()
@staticmethod
async def w_to_be_visible(actual: Locator):
"""元素可见"""
- await expect(actual).to_be_visible()
+ await exp(actual).to_be_visible()
# @staticmethod
# async def w_not_to_have_actuals(actual: Locator, actuals: list):
# """选择已选择选项"""
- # await expect(actual).to_have_actuals(actuals)
+ # await exp(actual).to_have_actuals(actuals)
# @staticmethod
# def w_not_to_have_attribute(locating: Locator, name: str, actual: str):
# """元素不具有属性"""
- # expect(locating).not_to_have_attribute(name, actual)
+ # exp(locating).not_to_have_attribute(name, actual)
# @staticmethod
# @staticmethod
# def w_not_to_have_css(locating: Locator, name: str, actual: str):
# """元素不使用CSS"""
- # expect(locating).not_to_have_css(name, actual)
+ # exp(locating).not_to_have_css(name, actual)
# @staticmethod
# def w_not_to_have_id(locating: Locator, _id: str):
# """元素没有ID"""
- # expect(locating).not_to_have_id(_id)
+ # exp(locating).not_to_have_id(_id)
#
# @staticmethod
# def w_not_to_have_js_property(locating: Locator, name: str, actual):
# """元素不具有js属性"""
- # expect(locating).not_to_have_js_property(name, actual)
+ # exp(locating).not_to_have_js_property(name, actual)
#
# @staticmethod
# def w_not_to_have_text(locating: Locator, expected: str):
# """元素没有文本"""
- # expect(locating).not_to_have_text(expected)
+ # exp(locating).not_to_have_text(expected)
# @staticmethod
# def w_not_to_have_actual(locating: Locator, actual: str):
# """元素无价值"""
- # expect(locating).not_to_have_actual(actual)
+ # exp(locating).not_to_have_actual(actual)
#
# def w_to_be_attached(self, hidden_text: str):
# """待连接"""
- # expect(self.page.get_by_text(hidden_text)).to_be_attached()
+ # exp(self.page.get_by_text(hidden_text)).to_be_attached()
#
# def w_to_be_editable(self, hidden_text: str):
# """可编辑"""
# locator = self.page.get_by_role("textbox")
- # expect(locator).to_be_editable()
+ # exp(locator).to_be_editable()
# def w_to_be_enabled(self, hidden_text: str):
# """为空"""
# locator = self.page.locator("button.submit")
- # expect(locator).to_be_enabled()
+ # exp(locator).to_be_enabled()
# def w_to_be_focused(self, hidden_text: str):
# """聚焦"""
# locator = self.page.get_by_role("textbox")
- # expect(locator).to_be_focused()
+ # exp(locator).to_be_focused()
#
# def w_to_be_hidden(self, hidden_text: str):
# """隐藏"""
# locator = self.page.locator('.my-element')
- # expect(locator).to_be_hidden()
+ # exp(locator).to_be_hidden()
#
# def w_to_be_in_viewport(self, hidden_text: str):
# """待在视口中"""
# locator = self.page.get_by_role("button")
# # Make sure at least some part of element intersects viewport.
- # expect(locator).to_be_in_viewport()
+ # exp(locator).to_be_in_viewport()
# # Make sure element is fully outside of viewport.
- # expect(locator).not_to_be_in_viewport()
+ # exp(locator).not_to_be_in_viewport()
# # Make sure that at least half of the element intersects viewport.
- # expect(locator).to_be_in_viewport(ratio=0.5)
+ # exp(locator).to_be_in_viewport(ratio=0.5)
#
# def w_to_contain_text(self, hidden_text: str):
# """包含文本"""
# locator = self.page.locator('.title')
- # expect(locator).to_contain_text("substring")
- # expect(locator).to_contain_text(re.compile(r"\d messages"))
+ # exp(locator).to_contain_text("substring")
+ # exp(locator).to_contain_text(re.compile(r"\d messages"))
#
# def w_to_have_attribute(self, hidden_text: str):
# """具有属性"""
# locator = self.page.locator("input")
- # expect(locator).to_have_attribute("type", "text")
+ # exp(locator).to_have_attribute("type", "text")
#
# def w_to_have_class(self, hidden_text: str):
# """到保存类别"""
# locator = self.page.locator("#component")
- # expect(locator).to_have_class(re.compile(r"selected"))
- # expect(locator).to_have_class("selected row")
+ # exp(locator).to_have_class(re.compile(r"selected"))
+ # exp(locator).to_have_class("selected row")
#
# def w_to_have_count(self, hidden_text: str):
# """有计数"""
# locator = self.page.locator("list > .component")
- # expect(locator).to_have_count(3)
+ # exp(locator).to_have_count(3)
#
# def w_to_have_css(self, hidden_text: str):
# """使用CSS"""
# locator = self.page.get_by_role("button")
- # expect(locator).to_have_css("display", "flex")
+ # exp(locator).to_have_css("display", "flex")
#
# def w_to_have_id(self, hidden_text: str):
# """到id"""
# locator = self.page.get_by_role("textbox")
- # expect(locator).to_have_id("lastname")
+ # exp(locator).to_have_id("lastname")
#
# def w_to_have_js_property(self, hidden_text: str):
# """拥有js属性"""
# locator = self.page.locator(".component")
- # expect(locator).to_have_js_property("loaded", True)
+ # exp(locator).to_have_js_property("loaded", True)
#
# def w_to_have_text(self, hidden_text: str):
# """有文本"""
# locator = self.page.locator(".title")
- # expect(locator).to_have_text(re.compile(r"Welcome, Test User"))
- # expect(locator).to_have_text(re.compile(r"Welcome, .*"))
+ # exp(locator).to_have_text(re.compile(r"Welcome, Test User"))
+ # exp(locator).to_have_text(re.compile(r"Welcome, .*"))
#
# def w_to_have_actual(self, hidden_text: str):
# """有价值"""
# locator = self.page.locator("input[type=number]")
- # expect(locator).to_have_actual(re.compile(r"[0-9]"))
+ # exp(locator).to_have_actual(re.compile(r"[0-9]"))
diff --git a/MangoServer/PyAutoTest/auto_test/auto_ui/service/ui_test_run.py b/MangoServer/PyAutoTest/auto_test/auto_ui/service/ui_test_run.py
index c0d9551a..a8c48f46 100644
--- a/MangoServer/PyAutoTest/auto_test/auto_ui/service/ui_test_run.py
+++ b/MangoServer/PyAutoTest/auto_test/auto_ui/service/ui_test_run.py
@@ -141,9 +141,9 @@ class UiTestRun:
case_step_details_id=None,
project_product=data['project_product_id'],
url=page_obj.url,
- type=page_obj.type,
+ type=page_obj.project_product.client_type,
equipment_config=self.__get_web_config(
- test_object.value) if page_obj.type == DriveTypeEnum.WEB.value else self.__get_app_config(),
+ test_object.value) if page_obj.project_product.client_type == DriveTypeEnum.WEB.value else self.__get_app_config(),
environment_config=self.__environment_config(test_object, page_obj.project_product_id)
)
page_steps_model.element_list.append(ElementModel(
diff --git a/mango-console/src/views/uitest/page-steps/details/config.ts b/mango-console/src/views/uitest/page-steps/details/config.ts
index e8a5c788..974d2e59 100644
--- a/mango-console/src/views/uitest/page-steps/details/config.ts
+++ b/mango-console/src/views/uitest/page-steps/details/config.ts
@@ -1,4 +1,5 @@
import { reactive } from 'vue'
+import { Message } from '@arco-design/web-vue'
export interface Item {
value: string
label: string
@@ -74,6 +75,111 @@ export const columns = reactive([
},
])
+export const customForm = reactive([
+ {
+ label: 'key',
+ key: 'key',
+ value: '',
+ type: 'input',
+ required: true,
+ placeholder: '请输入key',
+ validator: function () {
+ return true
+ },
+ },
+ {
+ label: 'value',
+ key: 'value',
+ value: '',
+ type: 'input',
+ required: true,
+ placeholder: '请输入value',
+ validator: function () {
+ return true
+ },
+ },
+])
+export const sqlForm = reactive([
+ {
+ label: 'key_list',
+ key: 'key_list',
+ value: '',
+ type: 'textarea',
+ required: true,
+ placeholder: '请输入sql查询结果的key_list',
+ validator: function () {
+ if (this.value !== '') {
+ try {
+ this.value = JSON.parse(this.value)
+ } catch (e) {
+ Message.error('key_list值请输入json数据类型')
+ return false
+ }
+ }
+ return true
+ },
+ },
+ {
+ label: 'sql语句',
+ key: 'sql',
+ value: '',
+ type: 'textarea',
+ required: true,
+ placeholder: '请输入sql',
+ validator: function () {
+ return true
+ },
+ },
+])
+export const assForm = reactive([
+ {
+ label: '断言类型',
+ key: 'ass_type',
+ value: '',
+ type: 'cascader',
+ required: true,
+ placeholder: '请选择断言类型',
+ validator: function () {
+ return true
+ },
+ },
+ {
+ label: '选择元素',
+ key: 'ele_name',
+ value: '',
+ placeholder: '请选择locating',
+ required: false,
+ type: 'select',
+ validator: function () {
+ return true
+ },
+ },
+])
+export const eleForm = reactive([
+ {
+ label: '元素操作',
+ key: 'ope_type',
+ value: '',
+ type: 'cascader',
+ required: true,
+ placeholder: '请选择对元素的操作',
+ validator: function () {
+ return true
+ },
+ },
+ {
+ label: '选择元素',
+ key: 'ele_name',
+ value: '',
+ placeholder: '请选择locating',
+ required: false,
+ type: 'select',
+ validator: function () {
+ return true
+ },
+ },
+])
+
export const formItems = reactive([
{
label: '步骤类型',
diff --git a/mango-console/src/views/uitest/page-steps/details/index.vue b/mango-console/src/views/uitest/page-steps/details/index.vue
index ada71e00..259ef7f2 100644
--- a/mango-console/src/views/uitest/page-steps/details/index.vue
+++ b/mango-console/src/views/uitest/page-steps/details/index.vue
@@ -201,7 +201,7 @@
import { fieldNames } from '@/setting'
import { getFormItems } from '@/utils/datacleaning'
import { usePageData } from '@/store/page-data'
- import { columns, formItems, Item } from './config'
+ import { assForm, columns, customForm, eleForm, formItems, Item, sqlForm } from './config'
import {
deleteUiPageStepsDetailed,
getUiPageStepsDetailed,
@@ -246,125 +246,25 @@
(item) => item.key === 'ele_name' || formItems.some((item) => item.key === 'ope_type')
)
) {
- formItems.push(
- {
- label: '元素操作',
- key: 'ope_type',
- value: '',
- type: 'cascader',
- required: true,
- placeholder: '请选择对元素的操作',
- validator: function () {
- return true
- },
- },
- {
- label: '选择元素',
- key: 'ele_name',
- value: '',
- placeholder: '请选择locating',
- required: false,
- type: 'select',
- validator: function () {
- return true
- },
- }
- )
+ formItems.push(...eleForm)
}
} else if (event === 1) {
if (!formItems.some((item) => item.key === 'ass_type')) {
- formItems.push(
- {
- label: '断言类型',
- key: 'ass_type',
- value: '',
- type: 'cascader',
- required: true,
- placeholder: '请选择断言类型',
- validator: function () {
- return true
- },
- },
- {
- label: '选择元素',
- key: 'ele_name',
- value: '',
- placeholder: '请选择locating',
- required: false,
- type: 'select',
- validator: function () {
- return true
- },
- }
- )
+ formItems.push(...assForm)
}
} else if (event === 2) {
if (
!formItems.some((item) => item.key === 'sql') ||
!formItems.some((item) => item.key === 'key_list')
) {
- formItems.push(
- {
- label: 'key_list',
- key: 'key_list',
- value: '',
- type: 'textarea',
- required: true,
- placeholder: '请输入sql查询结果的key_list',
- validator: function () {
- if (this.value !== '') {
- try {
- this.value = JSON.parse(this.value)
- } catch (e) {
- Message.error('key_list值请输入json数据类型')
- return false
- }
- }
- return true
- },
- },
- {
- label: 'sql语句',
- key: 'sql',
- value: '',
- type: 'textarea',
- required: true,
- placeholder: '请输入sql',
- validator: function () {
- return true
- },
- }
- )
+ formItems.push(...sqlForm)
}
} else {
if (
!formItems.some((item) => item.key === 'key') ||
!formItems.some((item) => item.key === 'value')
) {
- formItems.push(
- {
- label: 'key',
- key: 'key',
- value: '',
- type: 'input',
- required: true,
- placeholder: '请输入key',
- validator: function () {
- return true
- },
- },
- {
- label: 'value',
- key: 'value',
- value: '',
- type: 'input',
- required: true,
- placeholder: '请输入value',
- validator: function () {
- return true
- },
- }
- )
+ formItems.push(...customForm)
}
}
}
diff --git a/mango-console/src/views/uitest/page/elements/config.ts b/mango-console/src/views/uitest/page/elements/config.ts
index 4c0eaebe..ab78cdfb 100644
--- a/mango-console/src/views/uitest/page/elements/config.ts
+++ b/mango-console/src/views/uitest/page/elements/config.ts
@@ -101,73 +101,43 @@ export const formItems: FormItem[] = reactive([
placeholder: '请输入元素下标',
},
])
-export const formItems1: FormItem[] = reactive([
+
+export const assForm = reactive([
{
- label: '步骤类型',
- key: 'type',
- value: 0,
- type: 'radio',
+ label: '断言类型',
+ key: 'ass_type',
+ value: '',
+ type: 'cascader',
required: true,
- placeholder: '请选择对元素的操作类型',
+ placeholder: '请选择断言类型',
validator: function () {
return true
},
},
-
+])
+export const eleForm = reactive([
{
label: '元素操作',
key: 'ope_type',
- value: null,
+ value: '',
type: 'cascader',
- required: false,
+ required: true,
placeholder: '请选择对元素的操作',
validator: function () {
return true
},
},
+])
+
+export const formItems1 = reactive([
{
- label: '元素操作值',
- key: 'ope_value',
- value: '',
- type: 'textarea',
- required: false,
- placeholder: '请输入对元素的操作内容',
- validator: function () {
- if (this.value !== '') {
- try {
- this.value = JSON.parse(this.value)
- } catch (e) {
- Message.error('元素操作值请输入json数据类型')
- return false
- }
- }
- return true
- },
- },
- {
- label: '断言类型',
- key: 'ass_type',
- value: null,
- type: 'cascader',
- required: false,
- placeholder: '请选择断言类型',
- },
- {
- label: '断言值',
- key: 'ass_value',
+ label: '步骤类型',
+ key: 'type',
value: '',
- type: 'textarea',
- required: false,
- placeholder: '请输入断言内容',
+ type: 'radio',
+ required: true,
+ placeholder: '请选择对元素的操作类型',
validator: function () {
- if (this.value !== '') {
- try {
- this.value = JSON.parse(this.value)
- } catch (e) {
- Message.error('断言值请输入json数据类型')
- return false
- }
- }
return true
},
},
diff --git a/mango-console/src/views/uitest/page/elements/index.vue b/mango-console/src/views/uitest/page/elements/index.vue
index 59267233..62904f03 100644
--- a/mango-console/src/views/uitest/page/elements/index.vue
+++ b/mango-console/src/views/uitest/page/elements/index.vue
@@ -126,24 +126,6 @@
style="width: 380px"
allow-search
allow-clear
- :disabled="data.isDisabledOpe"
- />
-
-
-
-
-
@@ -154,7 +136,6 @@
:default-value="item.value"
v-model="item.value"
allow-clear
- :disabled="data.isDisabledOpe"
/>
@@ -164,13 +145,28 @@
:default-value="item.value"
v-model="item.value"
allow-clear
- :disabled="data.isDisabledAss"
/>
+
+
+
+
+
@@ -200,6 +196,7 @@
} from '@/api/uitest'
import { getSystemEnumExp } from '@/api/system'
import { useEnvironment } from '@/store/modules/get-environment'
+ import { assForm, eleForm } from '@/views/uitest/page/elements/config'
const uEnvironment = useEnvironment()
const pageData: any = usePageData()
@@ -216,11 +213,10 @@
actionTitle: '添加元素',
eleExp: [],
totalSize: 0,
+ type: 0,
data: [],
ope: [],
ass: [],
- isDisabledOpe: false,
- isDisabledAss: true,
plainOptions: [
{ label: '操作', value: 0 },
{ label: '断言', value: 1 },
@@ -358,14 +354,88 @@
}
function changeStatus(event: number) {
- data.isDisabledOpe = event == 1
- data.isDisabledAss = event == 0
- formItems1.forEach((item) => {
- item.value = null
- })
- formItems1[0].value = event
+ data.type = event
+ for (let i = formItems1.length - 1; i >= 0; i--) {
+ if (formItems1[i].key !== 'type') {
+ formItems1.splice(i, 1)
+ }
+ }
+ if (event === 0) {
+ if (
+ !formItems1.some(
+ (item) => item.key === 'ele_name' || formItems1.some((item) => item.key === 'ope_type')
+ )
+ ) {
+ formItems1.push(...eleForm)
+ }
+ } else {
+ if (!formItems1.some((item) => item.key === 'ass_type')) {
+ formItems1.push(...assForm)
+ }
+ }
+ }
+ function upDataAssValue(value: any) {
+ const inputItem = findItemByValue(data.ass, value)
+ if (inputItem) {
+ const parameter: any = inputItem.parameter
+ Object.keys(parameter).forEach((key) => {
+ parameter[key] = ''
+ })
+ if (!formItems1.some((item) => item.key === 'ass_value')) {
+ formItems1.push({
+ label: '断言值',
+ key: 'ass_value',
+ value: JSON.stringify(parameter),
+ type: 'textarea',
+ required: true,
+ placeholder: '请输入断言内容',
+ validator: function () {
+ if (this.value !== '') {
+ try {
+ this.value = JSON.parse(this.value)
+ } catch (e) {
+ Message.error(this.placeholder || '')
+ return false
+ }
+ }
+ return true
+ },
+ })
+ }
+ }
}
+ function upDataOpeValue(value: any) {
+ const inputItem = findItemByValue(data.ope, value)
+ if (inputItem) {
+ const parameter: any = inputItem.parameter
+ Object.keys(parameter).forEach((key) => {
+ parameter[key] = ''
+ })
+
+ if (!formItems1.some((item) => item.key === 'ope_value')) {
+ formItems1.push({
+ label: '元素操作值',
+ key: 'ope_value',
+ value: JSON.stringify(parameter),
+ type: 'textarea',
+ required: true,
+ placeholder: '请输入对元素的操作内容',
+ validator: function () {
+ if (this.value !== '') {
+ try {
+ this.value = JSON.parse(this.value)
+ } catch (e) {
+ Message.error('元素操作值请输入json数据类型')
+ return false
+ }
+ }
+ return true
+ },
+ })
+ }
+ }
+ }
function onDataForm1() {
if (formItems1.every((it) => (it.validator ? it.validator() : true))) {
modalDialogRef1.value?.toggle()
@@ -374,7 +444,7 @@
value['id'] = data.id
value['page_id'] = pageData.record.id
value['project_product_id'] = pageData.record.project_product.id
- value['type'] = pageData.record.type
+ value['type'] = data.type
putUiUiElementTest(value)
.then((res) => {
Message.success(res.msg)
@@ -392,21 +462,6 @@
children?: Item[]
}
- function upDataAssValue(value: any) {
- const inputItem = findItemByValue(data.ass, value)
- if (inputItem) {
- const parameter: any = inputItem.parameter
- Object.keys(parameter).forEach((key) => {
- parameter[key] = ''
- })
- formItems1.forEach((item: any) => {
- if (item.key === 'ass_value') {
- item.value = JSON.stringify(parameter)
- }
- })
- }
- }
-
function findItemByValue(data: Item[], value: string): Item | undefined {
for (let i = 0; i < data.length; i++) {
const item = data[i]
@@ -423,22 +478,9 @@
return undefined
}
- function upDataOpeValue(value: string) {
- const inputItem = findItemByValue(data.ope, value)
- if (inputItem) {
- const parameter: any = inputItem.parameter
- Object.keys(parameter).forEach((key) => {
- parameter[key] = ''
- })
- formItems1.forEach((item: any) => {
- if (item.key === 'ope_value') {
- item.value = JSON.stringify(parameter)
- }
- })
- }
- }
-
function onDebug(record: any) {
+ changeStatus(0)
+
if (!uEnvironment.selectValue) {
Message.error('请先选择测试环境')
return
--
Gitee
From 85758255eb956bb6f9c2f3c1f5f72f9e7fb1d1e1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=AF=9B=E9=B9=8F?= <729164035@qq.com>
Date: Fri, 2 Aug 2024 17:10:21 +0800
Subject: [PATCH 10/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=AD=E8=A8=80?=
=?UTF-8?q?=E7=9A=84=E5=80=BC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../tools/assertion/public_assertion.py | 130 +++++++++---------
1 file changed, 65 insertions(+), 65 deletions(-)
diff --git a/MangoServer/PyAutoTest/tools/assertion/public_assertion.py b/MangoServer/PyAutoTest/tools/assertion/public_assertion.py
index 5728e345..45e75beb 100644
--- a/MangoServer/PyAutoTest/tools/assertion/public_assertion.py
+++ b/MangoServer/PyAutoTest/tools/assertion/public_assertion.py
@@ -10,167 +10,167 @@ class WhatIsItAssertion:
"""是什么"""
@staticmethod
- def p_is_not_none(value):
+ def p_is_not_none(actual):
"""不是null"""
- assert_that(value).is_not_none()
+ assert_that(actual).is_not_none()
@staticmethod
- def p_is_none(value):
+ def p_is_none(actual):
"""是null"""
- assert_that(value).is_none()
+ assert_that(actual).is_none()
@staticmethod
- def p_is_empty(value):
+ def p_is_empty(actual):
"""是空字符串"""
- assert_that(value).is_empty()
+ assert_that(actual).is_empty()
@staticmethod
- def p_is_not_empty(value):
+ def p_is_not_empty(actual):
"""不是空符串"""
- assert_that(value).is_not_empty()
+ assert_that(actual).is_not_empty()
@staticmethod
- def p_is_false(value):
+ def p_is_false(actual):
"""是false"""
- assert_that(value).is_false()
+ assert_that(actual).is_false()
@staticmethod
- def p_is_true(value):
+ def p_is_true(actual):
"""是true"""
- assert_that(value).is_true()
+ assert_that(actual).is_true()
@staticmethod
- def p_is_alpha(value):
+ def p_is_alpha(actual):
"""是字母"""
- assert_that(value).is_alpha()
+ assert_that(actual).is_alpha()
@staticmethod
- def p_is_digit(value):
+ def p_is_digit(actual):
"""是数字"""
- assert_that(value).is_digit()
+ assert_that(actual).is_digit()
class WhatIsEqualToAssertion:
"""等于什么"""
@staticmethod
- def p_is_equal_to(value, expect):
+ def p_is_equal_to(actual, expect):
"""等于expect"""
- assert_that(value).is_equal_to(expect)
+ assert_that(actual).is_equal_to(expect)
@staticmethod
- def p_is_not_equal_to(value, expect):
+ def p_is_not_equal_to(actual, expect):
"""不等于expect"""
- assert_that(value).is_not_equal_to(expect)
+ assert_that(actual).is_not_equal_to(expect)
@staticmethod
- def p_is_length(value, expect):
+ def p_is_length(actual, expect):
"""长度等于expect"""
- assert_that(value).is_length(expect)
+ assert_that(actual).is_length(expect)
class ContainAssertion:
"""包含什么"""
@staticmethod
- def p_contains(value, expect):
+ def p_contains(actual, expect):
"""包含expect"""
- assert_that(value).contains(**expect)
+ assert_that(actual).contains(**expect)
@staticmethod
- def p_is_equal_to_ignoring_case(value, expect):
+ def p_is_equal_to_ignoring_case(actual, expect):
"""忽略大小写等于expect"""
- assert_that(value).is_equal_to_ignoring_case(expect)
+ assert_that(actual).is_equal_to_ignoring_case(expect)
@staticmethod
- def p_contains_ignoring_case(value, expect):
+ def p_contains_ignoring_case(actual, expect):
"""包含忽略大小写expect"""
- assert_that(value).contains_ignoring_case(expect)
+ assert_that(actual).contains_ignoring_case(expect)
@staticmethod
- def p_contains_only(value, expect):
+ def p_contains_only(actual, expect):
"""仅包含expect"""
- assert_that(value).contains_only(expect)
+ assert_that(actual).contains_only(expect)
@staticmethod
- def p_does_not_contain(value, expect):
+ def p_does_not_contain(actual, expect):
"""不包含expect"""
- assert_that(value).does_not_contain(expect)
+ assert_that(actual).does_not_contain(expect)
class MatchingAssertion:
"""匹配什么"""
@staticmethod
- def p_is_in(value, expect):
+ def p_is_in(actual, expect):
"""在expect里面"""
- assert_that(value).is_in(**expect)
+ assert_that(actual).is_in(**expect)
@staticmethod
- def p_is_not_in(value, expect):
+ def p_is_not_in(actual, expect):
"""不在expect里面"""
- assert_that(value).is_not_in(expect)
+ assert_that(actual).is_not_in(expect)
@staticmethod
- def p_starts_with(value, expect):
+ def p_starts_with(actual, expect):
"""以expect开头"""
- assert_that(value).starts_with(expect)
+ assert_that(actual).starts_with(expect)
@staticmethod
- def p_ends_with(value, expect):
+ def p_ends_with(actual, expect):
"""以expect结尾"""
- assert_that(value).ends_with(expect)
+ assert_that(actual).ends_with(expect)
@staticmethod
- def p_matches(value, expect):
+ def p_matches(actual, expect):
"""正则匹配等于expect"""
- assert_that(value).matches(expect)
+ assert_that(actual).matches(expect)
@staticmethod
- def p_does_not_match(value, expect):
+ def p_does_not_match(actual, expect):
"""正则不匹配expect"""
- assert_that(value).does_not_match(expect)
+ assert_that(actual).does_not_match(expect)
class PublicAssertion(WhatIsItAssertion, ContainAssertion, MatchingAssertion, WhatIsEqualToAssertion):
pass
# @staticmethod
- # def p_is_unicode(value):
- # """value是unicode"""
- # assert_that(value).is_unicode()
+ # def p_is_unicode(actual):
+ # """actual是unicode"""
+ # assert_that(actual).is_unicode()
# @staticmethod
- # def p_is_iterable(value):
- # """value是可迭代对象"""
- # assert_that(value).is_iterable()
+ # def p_is_iterable(actual):
+ # """actual是可迭代对象"""
+ # assert_that(actual).is_iterable()
# @staticmethod
- # def p_is_type_of(value, type_):
+ # def p_is_type_of(actual, type_):
# """判断类型"""
- # assert_that(value).is_type_of(eval(type_))
+ # assert_that(actual).is_type_of(eval(type_))
# @staticmethod
- # def p_is_instance_of(value, type_):
+ # def p_is_instance_of(actual, type_):
# """是实例-未测试"""
- # assert_that(value).is_instance_of(type_)
+ # assert_that(actual).is_instance_of(type_)
# @staticmethod
- # def p_is_subset_of(value, expect):
+ # def p_is_subset_of(actual, expect):
# """在里面"""
- # assert_that(value).is_subset_of(expect)
+ # assert_that(actual).is_subset_of(expect)
# @staticmethod
- # def p_contains_sequence(value, expect):
+ # def p_contains_sequence(actual, expect):
# """包含序列"""
- # assert_that(value).contains_sequence(expect)
+ # assert_that(actual).contains_sequence(expect)
# @staticmethod
- # def p_contains_duplicates(value):
+ # def p_contains_duplicates(actual):
# """仅包含"""
- # assert_that(value).contains_duplicates()
+ # assert_that(actual).contains_duplicates()
#
# @staticmethod
- # def p_does_not_contain_duplicates(value):
+ # def p_does_not_contain_duplicates(actual):
# """不包含重复项"""
- # assert_that(value).does_not_contain_duplicates()
+ # assert_that(actual).does_not_contain_duplicates()
# @staticmethod
- # def p_is_upper(value):
- # """value在什么上面"""
- # assert_that(value).is_upper()
+ # def p_is_upper(actual):
+ # """actual在什么上面"""
+ # assert_that(actual).is_upper()
--
Gitee
From 726b65e47546f1f05f347a755e6573f858066d1a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=AF=9B=E9=B9=8F?= <729164035@qq.com>
Date: Fri, 2 Aug 2024 17:36:33 +0800
Subject: [PATCH 11/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=AD=E8=A8=80?=
=?UTF-8?q?=E7=9A=84=E5=80=BC=EF=BC=8Capi=E7=9A=84=E4=B9=9F=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
MangoActuator/desktop/window/window.py | 4 +--
.../auto_api/service/base_tools/dependence.py | 25 ++++++++++---------
.../auto_api/views/api_case_detailed.py | 1 -
.../PyAutoTest/tools/view/model_crud.py | 5 ++--
.../src/views/apitest/case/details/index.vue | 8 +++---
5 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/MangoActuator/desktop/window/window.py b/MangoActuator/desktop/window/window.py
index 1bf0662d..32bf15c8 100644
--- a/MangoActuator/desktop/window/window.py
+++ b/MangoActuator/desktop/window/window.py
@@ -11,7 +11,7 @@ from PySide6.QtCore import QThread
import service_conn
from enums.socket_api_enum import ToolsSocketEnum
from enums.system_enum import CacheDataKey2Enum
-from enums.tools_enum import CacheKeyEnum, CacheValueTypeEnum, SignalTypeEnum
+from enums.tools_enum import CacheKeyEnum, CacheValueTypeEnum, SignalTypeEnum, ClientTypeEnum
from tools.assertion import Assertion
from tools.data_processor import RandomFileData
from tools.data_processor.sql_cache import SqlCache
@@ -58,7 +58,7 @@ class Window(Ui_MainWindow):
send_list.append(
{CacheDataKey2Enum.ASSERTION_METHOD.value: json.dumps(Assertion.get_methods(), ensure_ascii=False)})
from service_conn.socket_conn.client_socket import ClientWebSocket
- ClientWebSocket().sync_send('设置缓存数据', func_name=ToolsSocketEnum.SET_OPERATION_OPTIONS.value, func_args=send_list)
+ ClientWebSocket().sync_send('设置缓存数据成功', func_name=ToolsSocketEnum.SET_OPERATION_OPTIONS.value,is_notice=ClientTypeEnum.WEB.value, func_args=send_list)
# 接受信号的槽函数
def signalLabel6(self, text):
diff --git a/MangoServer/PyAutoTest/auto_test/auto_api/service/base_tools/dependence.py b/MangoServer/PyAutoTest/auto_test/auto_api/service/base_tools/dependence.py
index 83730d80..e4a845dd 100644
--- a/MangoServer/PyAutoTest/auto_test/auto_api/service/base_tools/dependence.py
+++ b/MangoServer/PyAutoTest/auto_test/auto_api/service/base_tools/dependence.py
@@ -112,13 +112,13 @@ class CaseMethod(CommonBase, PublicAssertion):
if isinstance(res, list):
for res_dict in res:
for key, value in res_dict.items():
- self.set_cache(sql_obj.get('value'), str(value))
- log.info(f'{sql_obj.get("value")}sql写入的数据:{self.get_cache(sql_obj.get("value"))}')
+ self.set_cache(sql_obj.get('actual'), str(value))
+ log.info(f'{sql_obj.get("actual")}sql写入的数据:{self.get_cache(sql_obj.get("actual"))}')
def __posterior_response(self, response_text: dict, posterior_response: list[dict]):
for i in posterior_response:
value = self.get_json_path_value(response_text, i['key'])
- self.set_cache(i['value'], value)
+ self.set_cache(i['actual'], value)
@classmethod
def __posterior_sleep(cls, sleep: str):
@@ -130,8 +130,9 @@ class CaseMethod(CommonBase, PublicAssertion):
try:
if ass_response_value:
for i in ass_response_value:
- value = self.get_json_path_value(response_data, i['value'])
- _dict = {'value': str(value)}
+ print(i)
+ value = self.get_json_path_value(response_data, i['actual'])
+ _dict = {'actual': str(value)}
if i.get('expect'):
try:
_dict['expect'] = str(eval(i.get('expect')))
@@ -141,28 +142,28 @@ class CaseMethod(CommonBase, PublicAssertion):
getattr(self, method)(**_dict)
except AssertionError as error:
log.warning(error)
- self.ass_result.append({'断言类型': method, '预期值': _dict.get('expect'), '实际值': _dict.get('value')})
+ self.ass_result.append({'断言类型': method, '预期值': _dict.get('expect'), '实际值': _dict.get('actual')})
raise ResponseValueAssError(*ERROR_MSG_0005)
@retry(stop_max_attempt_number=5, wait_fixed=1000)
def __assertion_sql(self, sql_list: list[dict]):
- _dict = {'value': None}
+ _dict = {'actual': None}
method = None
try:
if self.mysql_connect:
for sql in sql_list:
- value = self.mysql_connect.condition_execute(self.replace(sql.get('value')))
- if not value:
+ actual = self.mysql_connect.condition_execute(self.replace(sql.get('actual')))
+ if not actual:
raise SqlResultIsNoneError(*ERROR_MSG_0041)
- if isinstance(value, list):
- _dict = {'value': str(list(value[0].values())[0])}
+ if isinstance(actual, list):
+ _dict = {'actual': str(list(actual[0].values())[0])}
if sql.get('expect'):
_dict['expect'] = sql.get('expect')
method = sql.get('method')
getattr(self, method)(**_dict)
except AssertionError as error:
log.warning(error)
- self.ass_result.append({'断言类型': method, '预期值': _dict.get('expect'), '实际值': _dict.get('value')})
+ self.ass_result.append({'断言类型': method, '预期值': _dict.get('expect'), '实际值': _dict.get('actual')})
raise SqlAssError(*ERROR_MSG_0006)
def __assertion_response_whole(self, actual, expect):
diff --git a/MangoServer/PyAutoTest/auto_test/auto_api/views/api_case_detailed.py b/MangoServer/PyAutoTest/auto_test/auto_api/views/api_case_detailed.py
index 06cbf48f..f52516ee 100644
--- a/MangoServer/PyAutoTest/auto_test/auto_api/views/api_case_detailed.py
+++ b/MangoServer/PyAutoTest/auto_test/auto_api/views/api_case_detailed.py
@@ -133,7 +133,6 @@ class ApiCaseDetailedViews(ViewSet):
obj.case_sort = i['case_sort']
case_id = obj.case.id
obj.save()
- print(case_id)
ApiCaseDetailedCRUD().callback(case_id)
return ResponseData.success(RESPONSE_MSG_0013, )
diff --git a/MangoServer/PyAutoTest/tools/view/model_crud.py b/MangoServer/PyAutoTest/tools/view/model_crud.py
index c375c3f9..aa692653 100644
--- a/MangoServer/PyAutoTest/tools/view/model_crud.py
+++ b/MangoServer/PyAutoTest/tools/view/model_crud.py
@@ -118,12 +118,13 @@ class ModelCRUD(GenericAPIView):
if hasattr(self, 'callback'):
from PyAutoTest.auto_test.auto_ui.views.ui_page_steps_detailed import UiPageStepsDetailedCRUD
from PyAutoTest.auto_test.auto_ui.views.ui_case_steps_detailed import UiCaseStepsDetailedCRUD
- # from PyAutoTest.auto_test.auto_api.views.api_case_detailed import ApiCaseDetailedCRUD
+ from PyAutoTest.auto_test.auto_api.views.api_case_detailed import ApiCaseDetailedCRUD, ApiCaseDetailed
if isinstance(self, UiPageStepsDetailedCRUD):
parent_id = request.data.get('page_step')
elif isinstance(self, UiCaseStepsDetailedCRUD):
parent_id = request.data.get('case')
-
+ elif isinstance(self, ApiCaseDetailedCRUD):
+ parent_id = ApiCaseDetailed.objects.get(id=request.data.get('id')).case.id
else:
parent_id = request.data.get('id')
if parent_id is None:
diff --git a/mango-console/src/views/apitest/case/details/index.vue b/mango-console/src/views/apitest/case/details/index.vue
index 1b993953..2063da4d 100644
--- a/mango-console/src/views/apitest/case/details/index.vue
+++ b/mango-console/src/views/apitest/case/details/index.vue
@@ -822,13 +822,13 @@
if ('10' === data.tabsKey) {
data.selectDataObj.front_sql.push('请添加sql语句')
} else if ('31' === data.tabsKey) {
- data.selectDataObj.ass_response_value.push({ value: '', method: '', expect: '' })
+ data.selectDataObj.ass_response_value.push({ actual: '', method: '', expect: '' })
} else if ('32' === data.tabsKey) {
- data.selectDataObj.ass_sql.push({ value: '', method: '', expect: '' })
+ data.selectDataObj.ass_sql.push({ actual: '', method: '', expect: '' })
} else if ('40' === data.tabsKey) {
- data.selectDataObj.posterior_response.push({ key: '', value: '' })
+ data.selectDataObj.posterior_response.push({ key: '', actual: '' })
} else if ('41' === data.tabsKey) {
- data.selectDataObj.posterior_sql.push({ key: '', value: '' })
+ data.selectDataObj.posterior_sql.push({ key: '', actual: '' })
}
}
--
Gitee
From 470e67652a513102ad39532f78fbadec465845f6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=AF=9B=E9=B9=8F?= <729164035@qq.com>
Date: Fri, 2 Aug 2024 17:58:11 +0800
Subject: [PATCH 12/15] =?UTF-8?q?=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
MangoActuator/tools/message/error_msg.py | 2 +-
mango-console/src/views/uitest/case/details/index.vue | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/MangoActuator/tools/message/error_msg.py b/MangoActuator/tools/message/error_msg.py
index 9c42689c..0b0db721 100644
--- a/MangoActuator/tools/message/error_msg.py
+++ b/MangoActuator/tools/message/error_msg.py
@@ -27,7 +27,7 @@ ERROR_MSG_0021 = (321, '元素未找到,请检查断言前操作是否正常
ERROR_MSG_0022 = (322, '页面无此元素,请检查传入的元素是否正确')
ERROR_MSG_0023 = (323, 'iframe中未找到此元素,请检查元素表达式是否是正确的')
ERROR_MSG_0024 = (324, '上传文件的元素必须要是input标签中的')
-ERROR_MSG_0025 = (325, '用例步骤的数据取不到,请检查用例数据或联系管理员')
+ERROR_MSG_0025 = (325, '用例步骤的数据取不到,请检查是否对步骤进行了修改,而用例未更新')
ERROR_MSG_0026 = (326, '文件不存在')
ERROR_MSG_0027 = (
327, '您元素的操作内容中没有任何的数据,请检查:1.页面步骤详情中字段->元素操作值是否是空,是空可能是你删除了,也可能是执行器的操作选项没有同步需要点击执行器的同步发送缓存数据;2.元素表达式错误导致查询不到元素;')
diff --git a/mango-console/src/views/uitest/case/details/index.vue b/mango-console/src/views/uitest/case/details/index.vue
index 0922ac21..c543205d 100644
--- a/mango-console/src/views/uitest/case/details/index.vue
+++ b/mango-console/src/views/uitest/case/details/index.vue
@@ -4,7 +4,7 @@
- 刷新页面
+ 刷新页面
执行
返回
--
Gitee
From 1b02142a2145d2a54736a13f5bf545e70194913c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=AF=9B=E9=B9=8F?= <729164035@qq.com>
Date: Mon, 5 Aug 2024 10:45:13 +0800
Subject: [PATCH 13/15] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA?=
=?UTF-8?q?=E5=BC=82=E5=B8=B8=E6=8D=95=E8=8E=B7=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
MangoActuator/autotest/ui/base_tools/__init__.py | 10 ++++++----
MangoActuator/tools/message/error_msg.py | 1 +
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/MangoActuator/autotest/ui/base_tools/__init__.py b/MangoActuator/autotest/ui/base_tools/__init__.py
index 1fb401c8..5ca5ec37 100644
--- a/MangoActuator/autotest/ui/base_tools/__init__.py
+++ b/MangoActuator/autotest/ui/base_tools/__init__.py
@@ -125,12 +125,14 @@ class ElementMain(WebDevice, AndroidDriver):
raise error
try:
func_doc = getattr(self, ope_type).__doc__
+ SignalSend.notice_signal_c(
+ f'准备操作->元素:{name}正在进行{func_doc},元素个数:{self.element_test_result.ele_quantity}')
except AttributeError:
raise ElementOpeNoneError(*ERROR_MSG_0048)
-
- SignalSend.notice_signal_c(
- f'准备操作->元素:{name}正在进行{func_doc},元素个数:{self.element_test_result.ele_quantity}')
- await self.action_element()
+ try:
+ await self.action_element()
+ except AttributeError:
+ raise ElementOpeNoneError(*ERROR_MSG_0054)
async def __ass(self, name, ope_type):
for key, expect in self.element_model.ass_value.items():
diff --git a/MangoActuator/tools/message/error_msg.py b/MangoActuator/tools/message/error_msg.py
index 0b0db721..79a1f62b 100644
--- a/MangoActuator/tools/message/error_msg.py
+++ b/MangoActuator/tools/message/error_msg.py
@@ -58,3 +58,4 @@ ERROR_MSG_0050 = (350, 'xpath定位未找到元素')
ERROR_MSG_0051 = (351, '请检查email_host是否正确,导致无法连接发送错误')
ERROR_MSG_0052 = (352, '元素:{} 进行断言时发生异常,请检查元素是否可以正常使用')
ERROR_MSG_0053 = (353, '该用例已经测试失败,在截图的时候发生未知异常!')
+ERROR_MSG_0054 = (354, '浏览器已被关闭,可能是手动关闭,用例失败!')
--
Gitee
From 4c0c5cf7a3eb7c495b7e038e17ace2dd98b7c4bb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=AF=9B=E9=B9=8F?= <729164035@qq.com>
Date: Mon, 5 Aug 2024 10:56:41 +0800
Subject: [PATCH 14/15] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=80=E4=BA=9B?=
=?UTF-8?q?=E5=BC=82=E5=B8=B8=E6=8D=95=E8=8E=B7=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../autotest/ui/base_tools/__init__.py | 54 +++++++------------
1 file changed, 19 insertions(+), 35 deletions(-)
diff --git a/MangoActuator/autotest/ui/base_tools/__init__.py b/MangoActuator/autotest/ui/base_tools/__init__.py
index 5ca5ec37..995c3767 100644
--- a/MangoActuator/autotest/ui/base_tools/__init__.py
+++ b/MangoActuator/autotest/ui/base_tools/__init__.py
@@ -29,45 +29,29 @@ class ElementMain(WebDevice, AndroidDriver):
self.element_model = element_model
self.element_data = element_data
self.drive_type = drive_type
+ if element_model.name:
+ self.ope_name = element_model.name
+ else:
+ self.ope_name = element_model.ope_type if element_model.ope_type else element_model.ass_type
+ self.element_test_result = ElementResultModel(
+ test_suite_id=self.test_suite_id,
+ case_id=self.case_id,
+ page_step_id=self.page_step_id,
+ ele_name=self.ope_name,
+ exp=element_model.exp,
+ sub=element_model.sub,
+ sleep=element_model.sleep,
+ ope_type=element_model.ope_type,
+ ass_type=element_model.ass_type,
+ status=StatusEnum.FAIL.value,
+ ele_quantity=0,
+ )
try:
- if element_model.name:
- self.ope_name = element_model.name
- elif element_model.ope_type:
- self.ope_name = element_model.ope_type
- else:
- self.ope_name = element_model.ass_type
for key, value in self.element_model:
value = self.data_processor.replace(value)
setattr(self.element_model, key, value)
except MangoActuatorError as error:
- self.element_test_result = ElementResultModel(
- test_suite_id=self.test_suite_id,
- case_id=self.case_id,
- page_step_id=self.page_step_id,
- ele_name=self.ope_name,
- exp=element_model.exp,
- sub=element_model.sub,
- sleep=element_model.sleep,
- ope_type=element_model.ope_type,
- ass_type=element_model.ass_type,
- status=StatusEnum.FAIL.value,
- ele_quantity=0,
- )
raise error
- else:
- self.element_test_result = ElementResultModel(
- test_suite_id=self.test_suite_id,
- case_id=self.case_id,
- page_step_id=self.page_step_id,
- ele_name=self.ope_name,
- exp=element_model.exp,
- sub=element_model.sub,
- sleep=element_model.sleep,
- ope_type=element_model.ope_type,
- ass_type=element_model.ass_type,
- status=StatusEnum.FAIL.value,
- ele_quantity=0,
- )
@async_memory
async def element_main(self) -> None:
@@ -119,8 +103,8 @@ class ElementMain(WebDevice, AndroidDriver):
else:
# 清洗元素需要的数据
self.element_model.ope_value[key] = await self.__input_value(key, value)
- # except AttributeError:
- # raise ElementOpeNoneError(*ERROR_MSG_0027)
+ except AttributeError:
+ raise ElementOpeNoneError(*ERROR_MSG_0027)
except UiError as error:
raise error
try:
--
Gitee
From ddf15e022fb42e06d5c2f9675501072ee58630ed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=AF=9B=E9=B9=8F?= <729164035@qq.com>
Date: Tue, 6 Aug 2024 09:52:23 +0800
Subject: [PATCH 15/15] =?UTF-8?q?=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
MangoActuator/autotest/ui/service/case_main.py | 18 ++++--------------
.../autotest/ui/service/case_steps.py | 15 +++++++--------
MangoServer/PyAutoTest/settings/dev.py | 11 +++++++----
3 files changed, 18 insertions(+), 26 deletions(-)
diff --git a/MangoActuator/autotest/ui/service/case_main.py b/MangoActuator/autotest/ui/service/case_main.py
index 4a8fcabb..0e0d0d0d 100644
--- a/MangoActuator/autotest/ui/service/case_main.py
+++ b/MangoActuator/autotest/ui/service/case_main.py
@@ -7,10 +7,8 @@
import asyncio
from autotest.ui.service.case_steps import CaseSteps
-from enums.socket_api_enum import UiSocketEnum
from models.socket_model.ui_model import CaseModel
from tools.decorator.memory import async_memory
-from tools.public_methods import async_global_exception
from ..base_tools.driver_object import DriverObject
@@ -36,15 +34,7 @@ class CaseMain:
@async_memory
async def execute_task(self, case_model: CaseModel):
async with CaseSteps(case_model, self.driver_object) as obj:
- try:
- await obj.case_init()
- await obj.case_page_step()
- except Exception as error:
- await async_global_exception(
- 'execute_task',
- error,
- UiSocketEnum.CASE_RESULT.value,
- obj.case_result
- )
- finally:
- self.running_tasks -= 1
+ await obj.case_init()
+ await obj.case_page_step()
+
+ self.running_tasks -= 1
diff --git a/MangoActuator/autotest/ui/service/case_steps.py b/MangoActuator/autotest/ui/service/case_steps.py
index 14af6cab..01e1f6ac 100644
--- a/MangoActuator/autotest/ui/service/case_steps.py
+++ b/MangoActuator/autotest/ui/service/case_steps.py
@@ -24,7 +24,6 @@ from tools.decorator.memory import async_memory
from tools.desktop.signal_send import SignalSend
from tools.log_collector import log
from tools.message.error_msg import ERROR_MSG_0037, ERROR_MSG_0039
-from tools.public_methods import async_global_exception
class CaseSteps(StepElements):
@@ -88,13 +87,13 @@ class CaseSteps(StepElements):
except MangoActuatorError as error:
self.case_result.error_message = f'用例<{self.case_model.name}> 失败原因:{error.msg}'
self.case_result.status = StatusEnum.FAIL.value
- except Exception as error:
- await async_global_exception(
- 'case_page_step',
- error,
- UiSocketEnum.CASE_RESULT.value,
- self.case_result
- )
+ # except Exception as error:
+ # await async_global_exception(
+ # 'case_page_step',
+ # error,
+ # UiSocketEnum.CASE_RESULT.value,
+ # self.case_result
+ # )
else:
msg = self.case_result.error_message if self.case_result.error_message else f'用例<{self.case_model.name}>测试完成'
await ClientWebSocket().async_send(
diff --git a/MangoServer/PyAutoTest/settings/dev.py b/MangoServer/PyAutoTest/settings/dev.py
index aa177024..35d0f82c 100644
--- a/MangoServer/PyAutoTest/settings/dev.py
+++ b/MangoServer/PyAutoTest/settings/dev.py
@@ -10,11 +10,14 @@ IS_SQLITE = False # 是否选用mysql作为数据源
# ************************ Mysql配置 ************************ #
mysql_port = 3306
-mysql_db_name = 'test'
+# mysql_db_name = 'test'
+# mysql_user = 'root'
+# mysql_password = 'mP123456&'
+# mysql_ip = '127.0.0.1'
+mysql_db_name = 'auto_test'
mysql_user = 'root'
-mysql_password = 'mP123456&'
-mysql_ip = '127.0.0.1'
-
+mysql_password = 'Root@123'
+mysql_ip = '172.16.100.26'
# ************************ DEBUG配置 ************************ #
DEBUG = True
--
Gitee