Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复归档工单无法获取到资源组的问题 #2779

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions sql/utils/test_workflow_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,6 @@ def test_init_no_workflow_and_audit():
assert "WorkflowAudit 或 workflow" in str(e.value)


def test_archive_init_no_resource_group(archive_apply):
"""测试 archive 初始化时指定的资源组不存在"""
with pytest.raises(AuditException) as e:
AuditV2(workflow=archive_apply, resource_group="not_exists_group")
assert "参数错误, 未发现资源组" in str(e.value)
Comment on lines -360 to -364
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? 怎么把这个测试删掉了, 这种情况需要考虑的吧

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果时通过resource_group_id来获取resource_group的话,这里好像不存在资源组不存在的情况?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个你说的可能不太现实, 你可以确认下前端是传名字还是 ID, 你如果想要做这个功能, 你要确认前端是只传 ID, 不然可能会造成混淆, 我当时是重构的时候为了防止出错原样照搬了, 如果你想优化流程, 你需要去确认这个影响范围.



def test_duplicate_create(sql_query_apply, fake_generate_audit_setting):
audit = AuditV2(workflow=sql_query_apply)
audit.create_audit()
Expand Down
4 changes: 3 additions & 1 deletion sql/utils/workflow_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ def __post_init__(self):
self.resource_group_id = self.workflow.group_id
elif isinstance(self.workflow, ArchiveConfig):
try:
group_in_db = ResourceGroup.objects.get(group_name=self.resource_group)
group_in_db = ResourceGroup.objects.get(
group_id=self.workflow.resource_group_id
)
self.resource_group_id = group_in_db.group_id
except ResourceGroup.DoesNotExist:
raise AuditException(f"参数错误, 未发现资源组 {self.resource_group}")
Expand Down
Loading