applications: fix confirm page with empty response from bundle-check (#82703)
gitea/hobo/pipeline/head This commit looks good Details

This commit is contained in:
Lauréline Guérin 2023-10-24 10:40:20 +02:00 committed by Lauréline Guérin
parent 34c88ba2fc
commit 2660050395
2 changed files with 21 additions and 3 deletions

View File

@ -571,11 +571,11 @@ class AsyncJob(models.Model):
no_history = collections.defaultdict(list)
for service in self.details.values():
for data in service.values():
for diff in data.get('differences'):
for diff in data.get('differences') or []:
diffs[diff['type']][diff['slug']] = diff['url']
for unknown in data.get('unknown_elements'):
for unknown in data.get('unknown_elements') or []:
not_found[unknown['type']].append(unknown['slug'])
for history in data.get('no_history_elements'):
for history in data.get('no_history_elements') or []:
no_history[history['type']].append(history['slug'])
result_diffs = []
result_not_found = []

View File

@ -1182,6 +1182,24 @@ def test_update_application(app, admin_user, settings, app_bundle):
]
assert 'Error checking local changes, update can not be run.' in resp
def response_content(url, request): # noqa pylint: disable=function-redefined
if url.path == '/api/export-import/bundle-check/':
return {
'content': json.dumps({'data': {}}),
'status_code': 200,
}
return mocked_http(url, request)
resp = app.get('/applications/manifest/test/update/')
resp.form['bundle'] = Upload('app.tar', app_bundle, 'application/x-tar')
with StatefulHTTMock(response_content):
resp = resp.form.submit()
assert resp.location.endswith(
'/applications/manifest/test/confirm/%s/' % Version.objects.latest('pk').pk
)
resp = resp.follow()
assert 'No local changes found.' in resp
def test_get_version_to_check(app):
application = Application.objects.create(name='Test', slug='test')