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] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AE=9A=E6=97=B6=E4=BB=BB?=
=?UTF-8?q?=E5=8A=A1=E8=B7=9F=E9=9A=8F=E7=9A=84=E6=B5=8B=E8=AF=95=E7=8E=AF?=
=?UTF-8?q?=E5=A2=83=E7=BB=91=E5=AE=9A=EF=BC=88=E8=BF=98=E6=9C=89=E4=BC=98?=
=?UTF-8?q?=E5=8C=96=E7=AD=89=E5=BE=85=E5=90=8E=E7=BB=AD=E5=BC=80=E5=8F=91?=
=?UTF-8?q?=EF=BC=89=EF=BC=9B=E4=BF=AE=E5=A4=8Dapi=E6=8E=A5=E5=8F=A3?=
=?UTF-8?q?=E6=8E=92=E5=BA=8F=E6=8A=A5=E9=94=99=E7=9A=84=E5=BC=82=E5=B8=B8?=
=?UTF-8?q?=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