applications: build role during bundle generation (#82760)
gitea/hobo/pipeline/head This commit looks good Details

This commit is contained in:
Lauréline Guérin 2023-10-24 14:34:01 +02:00
parent 2660050395
commit 5a23834a4e
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 19 additions and 6 deletions

View File

@ -329,11 +329,16 @@ class Version(models.Model):
}
)
response = requests.get(element.cache['urls']['export'])
tarinfo = tarfile.TarInfo('%s/%s' % (element.type, element.slug))
tarinfo.mtime = self.last_update_timestamp.timestamp()
tarinfo.size = int(response.headers['content-length'])
tar.addfile(tarinfo, fileobj=io.BytesIO(response.content))
if element.type == 'roles':
role_element = json.dumps({'name': element.name, 'slug': element.slug}).encode()
tarinfo.size = len(role_element)
tar.addfile(tarinfo, fileobj=io.BytesIO(role_element))
else:
response = requests.get(element.cache['urls']['export'])
tarinfo.size = int(response.headers['content-length'])
tar.addfile(tarinfo, fileobj=io.BytesIO(response.content))
manifest_fd = io.BytesIO(json.dumps(manifest_json, indent=2).encode())
tarinfo = tarfile.TarInfo('manifest.json')

View File

@ -158,7 +158,13 @@ WCS_FORM_DEPENDENCIES = {
'export': 'https://wcs.example.invalid/api/export-import/cards/test-card/',
'dependencies': 'https://wcs.example.invalid/api/export-import/cards/test-card/dependencies/',
},
}
},
{
'id': 'test-role',
'text': 'Test Role',
'type': 'roles',
'urls': {}, # no urls in cache
},
]
}
@ -307,7 +313,7 @@ def test_create_application(app, admin_user, settings, analyze):
if analyze:
resp = resp.click('Scan dependencies').follow()
assert Application.objects.get(slug='test').elements.count() == 2
assert Application.objects.get(slug='test').elements.count() == 3
resp = resp.click('Generate application bundle')
resp.form['number'] = '1.0'
@ -1146,7 +1152,9 @@ def test_update_application(app, admin_user, settings, app_bundle):
assert 'Block of fields "test"' in resp
resp = resp.form.submit()
assert resp.location.endswith('/applications/manifest/test/')
assert list(AsyncJob.objects.filter(version__number='42.0').values_list('action', flat=True)) == [
assert list(
AsyncJob.objects.filter(version__number='42.0').values_list('action', flat=True).order_by('pk')
) == [
'check-install',
'deploy',
]