Commit 4b617670 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

Test for archive production

This will give us the means to test heptapod#204,
hence also omnibus-heptapod#12, since archive production
will be done by HGitaly.
parent 1899b83c14c3
Pipeline #11788 waiting for manual action with stage
......@@ -4,6 +4,7 @@ from selenium.common.exceptions import (
NoSuchElementException,
)
from selenium.webdriver.support.ui import WebDriverWait
import tarfile
from .utils import (
unique_name,
......@@ -416,3 +417,32 @@ def test_external_user_can_create_project(test_group, external_user):
# ugly hack until we can just pass a different user
project.owner = 'root'
project.api_destroy()
def test_archive(public_project, tmpdir):
repo_path = tmpdir.join('repo1')
repo = LocalRepo.init(repo_path,
default_url=public_project.owner_basic_auth_url)
repo_path.join('foo').write('archived')
repo.hg('commit', '-Am', "Commit 0")
node = repo.node('.')
repo.hg('push')
# python 3.9 apparently has a nicer syntax for multi-line with statements
# (not worth requiring it right away, of course)
# https://bugs.python.org/issue12782
with public_project.get_archive('branch/default') as arch_file, \
tarfile.open(fileobj=arch_file) as tarf:
toc = tarf.getnames()
main_dir = toc[0].split('/', 1)[0]
assert set(toc) == {main_dir + '/.hg_archival.txt',
main_dir + '/foo'}
extract_dir = tmpdir.join('extract')
tarf.extractall(path=extract_dir)
metadata_lines = extract_dir.join(main_dir,
'.hg_archival.txt').readlines()
assert 'node: %s\n' % node in metadata_lines
assert extract_dir.join(main_dir, 'foo').read() == 'archived'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment