archival: added tests at subpath generation of archivals
This commit is contained in:
parent
2ce60e2b22
commit
dbdf7a5bf0
3 changed files with 30 additions and 4 deletions
|
|
@ -72,6 +72,7 @@ def route_path(name, params=None, **kwargs):
|
|||
'repo_files_edit_file': '/{repo_name}/edit_file/{commit_id}/{f_path}',
|
||||
'repo_files_update_file': '/{repo_name}/update_file/{commit_id}/{f_path}',
|
||||
'repo_files_add_file': '/{repo_name}/add_file/{commit_id}/{f_path}',
|
||||
'repo_files_upload_file': '/{repo_name}/upload_file/{commit_id}/{f_path}',
|
||||
'repo_files_create_file': '/{repo_name}/create_file/{commit_id}/{f_path}',
|
||||
'repo_nodetree_full': '/{repo_name}/nodetree_full/{commit_id}/{f_path}',
|
||||
'repo_nodetree_full:default_path': '/{repo_name}/nodetree_full/{commit_id}/',
|
||||
|
|
@ -564,7 +565,31 @@ class TestRepositoryArchival(object):
|
|||
]
|
||||
|
||||
for header in headers:
|
||||
assert header in response.headers.items()
|
||||
assert header in list(response.headers.items())
|
||||
|
||||
def test_archival_at_path(self, backend):
|
||||
backend.enable_downloads()
|
||||
commit = backend.repo.get_commit(commit_idx=190)
|
||||
at_path = 'vcs'
|
||||
|
||||
for a_type, content_type, extension in settings.ARCHIVE_SPECS:
|
||||
path_sha = get_path_sha(at_path)
|
||||
filename = get_archive_name(backend.repo_name, commit_sha=commit.short_id, ext=extension, path_sha=path_sha)
|
||||
|
||||
fname = commit.raw_id + extension
|
||||
response = self.app.get(
|
||||
route_path('repo_archivefile',
|
||||
repo_name=backend.repo_name,
|
||||
fname=fname, params={'at_path': at_path}))
|
||||
|
||||
assert response.status == '200 OK'
|
||||
headers = [
|
||||
('Content-Disposition', 'attachment; filename=%s' % filename),
|
||||
('Content-Type', '%s' % content_type),
|
||||
]
|
||||
|
||||
for header in headers:
|
||||
assert header in list(response.headers.items())
|
||||
|
||||
@pytest.mark.parametrize('arch_ext',[
|
||||
'tar', 'rar', 'x', '..ax', '.zipz', 'tar.gz.tar'])
|
||||
|
|
|
|||
|
|
@ -315,7 +315,7 @@ class RepoFilesView(RepoAppView):
|
|||
|
||||
@region.conditional_cache_on_arguments(namespace=cache_namespace_uid, condition=cache_on)
|
||||
def compute_file_tree(_name_hash, _repo_id, _commit_id, _f_path, _full_load, _at_rev):
|
||||
log.debug('Generating cached file tree at ver:%s for repo_id: %s, %s, %s',
|
||||
log.debug('Generating cached file tree at for repo_id: %s, %s, %s',
|
||||
_repo_id, _commit_id, _f_path)
|
||||
|
||||
c.full_load = _full_load
|
||||
|
|
|
|||
|
|
@ -133,8 +133,9 @@ class TestArchives(BackendTestMixin):
|
|||
archive_node = tmp_path / 'archive-node'
|
||||
archive_node.touch()
|
||||
|
||||
archive_lnk = self.tip.archive_repo(str(archive_node), kind='zip',
|
||||
archive_dir_name='repo', write_metadata=True, cache_config=d_cache_config)
|
||||
archive_lnk = self.tip.archive_repo(
|
||||
str(archive_node), kind='zip',
|
||||
archive_dir_name='repo', write_metadata=True, cache_config=d_cache_config)
|
||||
|
||||
zip_file = zipfile.ZipFile(str(archive_lnk))
|
||||
metafile = zip_file.read('repo/.archival.txt')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue