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 committed by Lauréline Guérin
parent d96e8117fa
commit 2c97a5b217
2 changed files with 16 additions and 5 deletions

View File

@ -336,11 +336,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
},
]
}
@ -308,7 +314,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'