Commit f643d3d7 authored by Antoine Beaupré's avatar Antoine Beaupré

simplify a test fixture API

parent 99caedb6
......@@ -38,7 +38,7 @@ def test_usage():
def test_extract_render_chain(fake_repo, tmpdir):
repo, packages, files = fake_repo
repo = fake_repo
runner = CliRunner()
output = tmpdir.join('html')
result = runner.invoke(debmans, ['--output', str(output),
......
......@@ -58,15 +58,14 @@ Version: 8.6
Codename: jessie''')
with distdir.join('main', 'binary-all', 'Packages').open('w') as pkgfile:
pkgfile.write(pkgs_str)
return tmpdir, PACKAGES, files
return tmpdir
def test_extractor(fake_repo, tmpdir):
print(fake_repo)
mirrordir, packages, files = fake_repo
mirror = PackageMirror(str(mirrordir))
mirror = PackageMirror(str(fake_repo))
extractor = PackageExtractor([DefaultManpageRenderer.pattern],
root=str(mirrordir), destdir=str(tmpdir))
root=str(fake_repo), destdir=str(tmpdir))
for suite, pkg in mirror.packages:
print("found package: %s" % pkg.get('Filename'))
assert pkg.get('Filename') is not None
......@@ -79,16 +78,15 @@ def test_extractor(fake_repo, tmpdir):
def test_cache(fake_repo, tmpdir):
mp, pkgs = test_extractor(fake_repo, tmpdir)
mp = test_extractor(fake_repo, tmpdir)
assert len(mp) > 0, "extractor doesn't work"
assert len(list(tmpdir.join('.cache').visit())) == len(pkgs)
assert len(list(tmpdir.join('.cache').visit())) == len(PACKAGES)
with pytest.raises(AssertionError):
mp = test_extractor(fake_repo, tmpdir)
assert len(mp) == 0
def test_mirror(fake_repo, tmpdir):
mirrordir, packages, files = fake_repo
mirror = PackageMirror(str(mirrordir))
mirror = PackageMirror(str(fake_repo))
assert 'jessie' in mirror.releases
assert mirror.releases['jessie'] == '8.6 jessie (stable)'
......@@ -52,10 +52,9 @@ def test_static_render(tmpdir):
def test_manpage_rendering(fake_repo, tmpdir):
mirrordir, packages, files = fake_repo
manpages, _ = test_extractor(fake_repo, tmpdir)
template = find_static_file(os.path.join('static', 'template.html'))
suites = PackageMirror(str(mirrordir)).releases
suites = PackageMirror(str(fake_repo)).releases
print("releases: %s" % suites)
for manpage in manpages:
r = DefaultManpageRenderer(template)
......@@ -69,7 +68,6 @@ def test_manpage_rendering(fake_repo, tmpdir):
def test_manpage_render_only(fake_repo, tmpdir):
mirrordir, packages, files = fake_repo
manpages, _ = test_extractor(fake_repo, tmpdir)
patterns = {}
patterns[DefaultManpageRenderer.pattern] = DefaultManpageRenderer
......
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