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 6a4c8b28f514b66b81280f01752ce0d24c6ecbde..a45f52c561fa75870a561db0bd5e4e8fbd9cc7fa 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 f30dddf74cf93adc6a4e032cf7abea4fed4e65e4..361b765e348771050188f67344321010708e37e8 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 685ad816848bd15be8470dd9c3dd2c5886b0d3b3..83730d803d4e59533711319a30fa4a3aaf8877a6 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 c483433183b8a52d725cf6b39c376658b8ecffc2..2576294aa28cd8140e13a1620e3f1a4c518198de 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 f4846ed4f95ddb2ab745f37273fdce4e556aad0e..06cbf48f02ed4f4be64ff87b766070995306c6e0 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 0000000000000000000000000000000000000000..c2f0d16e8c554303a4e1a605b7ac1391ada8e417 --- /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 8be02c35fe7107b343741ac26a3a5694fb6cdf59..c3af8638a42f70a71f01d5ce8466fab797aa831d 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 e27909779ae9b919115704f2a0258927de9c66da..5f23586a2c3b68afe3b9f1d687f0f0967c1d0b56 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 0d2525fa110ac672208f58cb4b0b81134b767e5c..82ae1143854f4e07d46cbc03509e7f4fd652c941 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 98f496934c719ff5f89e36a9487d7f1372577a0f..498c8aad88f8a176bc11f9dbf65eefa711f17856 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 21ec7c201d649df51e120c057cb27e56102f75e1..427dfd2825055873212456e6267288087151b78d 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 21f4f74e8056c338f7a27f844145a6f4ad363eed..7818755afb0e2557a82d9988db6f5db7c8e5af4b 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 c6c18c2e6957a198859e9b6063469ea490e7a273..c4ee0433b633e0bed91d8d75dcf75be1feba1dea 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 b9241f6ed6a8a695c43f3c5487c621b165898dfa..0126aac915143b0a927707318060c82d1e641a8c 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 35a58a22546ba7db8074e8bf796cdf944050dfe9..a695c2af9024a5978a992ca8ea43ac277c144f4a 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 c82789299c7c1d64134bce542e005c6531767570..b97fbb1c2b5024219138c55da9538077265907d4 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 02eb192396a0564945a91de4727f7249aa68b7c0..dbf33c607bb3e5d9f96fb8548a47124b98cbfacc 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 49f74c7db1d2f1721407ca2cc48d5d750a699571..005a02f11a4046c37a4d6c9dd0c0b0138756bf4c 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 0b6c36ac12615523ff690251743f3e11adb9753a..57f89cf7f8d88ebaac6c8bb0afad4aac369360b4 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 0000000000000000000000000000000000000000..0c479797282f771c955c54d5302e9a23816c71cf --- /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 4224659947dbf5d83241eaa1c6ad7f98fe494e21..7eb686bbc8019c6d5bc20fd7fcd8030205ec5848 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 7167234eecd8c28f7b51c0f06f1c5b257dcf2ebf..f3cfcc7a78309297a379330ad510d36594a2f683 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 f1f12c512c4b79e9138612d8c04776a87a8b5c43..e78c80cbcf1357d5d0d9441e08c12dc7f8fe0502 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 41a7eda4fed99ca334bf515fce9b7515d8fe6f54..d70b607099973f970d56e6f9f260bca06cbc623c 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 777199d4ae81b2530c3f314a6c874133d144f88d..9cd2888e2a190f1853bd0fcc8f84f09d26bb7c67 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 4b06b2ccaac2edd1919e3d868b1f4bddf3e9bb15..66aa3fd19171cf57928aa156e2806df83ed69641 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 2d2f675fdfdf8649700458014d84c4ec657cef1a..651ffa0cdff94fbbbe43cc37df4412f3b9f65156 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 bb09f1c7690360d2d3805eac5cdd519d6017a3d7..38e1d40d3419d916b6b3f6902bbc2ce8f74e1a59 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 9bfa22a459c02a6e74e4caf2c6f8d03f635438dc..87b31b73f459bf3d8194fd9e8a83fbdf56fb9c35 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 @@ -