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

fix(api/web): fix resource_version diff #1081

Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,11 @@ def get(self, request, *args, **kwargs):
source_resource_version_id = data.get("source_resource_version_id")
target_resource_version_id = data.get("target_resource_version_id")

# 如果 source_resource_version_id 为空,需要将 source_resource_data 置为空,相当于
# target_resource_data 和 空版本对比
# 如果 source_resource_version_id和target_resource_version_id都为空(版本对比没有历史版本的时候),
# 需要将 source_resource_data 置为空,相当于target_resource_data 和 空版本对比
source_resource_data = (
Han-Ya-Jun marked this conversation as resolved.
Show resolved Hide resolved
ResourceVersionHandler.get_data_by_id_or_new(request.gateway, source_resource_version_id)
if source_resource_version_id
if source_resource_version_id or target_resource_version_id
else []
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,29 +95,39 @@ def test_release_with_hosts(
class TestReleaseAvailableResourceListApi:
def test_list(self, request_view, fake_gateway, fake_stage):
stage_1 = G(Stage, gateway=fake_gateway, name="prod", status=0)
resource_version = G(ResourceVersion, gateway=fake_gateway, _data=json.dumps([{
"id": 1,
"name": "test",
"method": "get",
"path": "/test/",
"description": "test...",
"description_en": "",
"match_subpath": "",
"is_public": True,
"allow_apply_permission": True,
"disabled_stages": [],
"contexts": {
"resource_auth": {
"config": json.dumps({
"app_verified_required": True,
"skip_auth_verification": True,
"auth_verified_required": True,
"resource_perm_required": True
})
}
},
"api_labels": "",
}]))
resource_version = G(
ResourceVersion,
gateway=fake_gateway,
_data=json.dumps(
[
{
"id": 1,
"name": "test",
"method": "get",
"path": "/test/",
"description": "test...",
"description_en": "",
"match_subpath": "",
"is_public": True,
"allow_apply_permission": True,
"disabled_stages": [],
"contexts": {
"resource_auth": {
"config": json.dumps(
{
"app_verified_required": True,
"skip_auth_verification": True,
"auth_verified_required": True,
"resource_perm_required": True,
}
)
}
},
"api_labels": "",
}
]
),
)

G(Release, gateway=fake_gateway, stage=stage_1, resource_version=resource_version)

Expand All @@ -130,9 +140,22 @@ def test_list(self, request_view, fake_gateway, fake_stage):
result = response.json()

assert response.status_code == 200
assert result == {'data': [{'id': 1, 'name': 'test', 'description': 'test...', 'method': 'get',
'path': '/test/', 'verified_user_required': False, 'verified_app_required': True,
'resource_perm_required': True, 'is_public': True, 'labels': []}]}
assert result == {
"data": [
{
"id": 1,
"name": "test",
"description": "test...",
"method": "get",
"path": "/test/",
"verified_user_required": False,
"verified_app_required": True,
"resource_perm_required": True,
"is_public": True,
"labels": [],
}
]
}


class TestReleaseResourceSchemaRetrieve:
Expand Down
Loading