Commit ca5e3403 authored by Adam Mercer's avatar Adam Mercer 💬

Merge branch 'test-updates' into 'master'

Test updates

See merge request packaging/koji-packager!7
parents 18449167 f99c14c5
......@@ -19,4 +19,4 @@
"""Python library for interacting with the Koji RPM build system
__version__ = "0.1.0"
__version__ = '0.1.0'
......@@ -24,13 +24,13 @@ from unittest import mock
from .. import build as gwkoji_build
@mock.patch("", return_value="/usr/bin/spectool")
@mock.patch('', return_value='/usr/bin/spectool')
def test_download_spec_sources(call, _):
gwkoji_build.download_spec_sources("test.spec", "outdir", logger=1)
gwkoji_build.download_spec_sources('test.spec', 'outdir', logger=1)
["/usr/bin/spectool", "--get-files", "--directory",
"outdir", "test.spec"],
['/usr/bin/spectool', '--get-files', '--directory',
'outdir', 'test.spec'],
......@@ -28,15 +28,15 @@ import pytest
from .. import options as gwkoji_options
@mock.patch.object(sys, "argv", ["gwkoji-packager", "test.spec", "--spec"])
@mock.patch.object(sys, 'argv', ['gwkoji-packager', 'test.spec', '--spec'])
def test_parse_options():
args = gwkoji_options.parse_options()
assert args.source == Path("test.spec")
assert args.source_type == "spec"
assert args.source == Path('test.spec')
assert args.source_type == 'spec'
@mock.patch.object(sys, "argv",
["gwkoji-packager", "test.spec", "--spec", "--tarball"])
@mock.patch.object(sys, 'argv',
['gwkoji-packager', 'test.spec', '--spec', '--tarball'])
def test_parse_options_exclusive_source_type():
with pytest.raises(SystemExit):
......@@ -25,12 +25,13 @@ from .. import utils as gwkoji_utils
@pytest.mark.parametrize("source, type_", [
("git+", "git"),
("mypackage.spec", "spec"),
("mypackage.src.rpm", "srcrpm"),
("mypackage.tar", "tarball"),
("mypackage.tar.gz", "tarball"),
("mypackage.tar.xz", "tarball"),
('git+', 'git'),
('mypackage.spec', 'spec'),
('mypackage.src.rpm', 'srcrpm'),
('mypackage.tar', 'tarball'),
('mypackage.tar.bz2', 'tarball'),
('mypackage.tar.gz', 'tarball'),
('mypackage.tar.xz', 'tarball'),
def test_source_type(source, type_):
assert gwkoji_utils.source_type(source) == type_
......@@ -38,4 +39,4 @@ def test_source_type(source, type_):
def test_source_type_error():
with pytest.raises(ValueError):
......@@ -77,13 +77,13 @@ def source_type(source):
source = pathlib.Path(source)
name =
if name.endswith(".src.rpm"):
if name.endswith('.src.rpm'):
return 'srcrpm'
if name.endswith(".spec"):
if name.endswith('.spec'):
return 'spec'
if name.endswith(".tar") or source.stem.endswith(".tar"):
if name.endswith('.tar') or source.stem.endswith('.tar'):
return 'tarball'
if str(source).startswith(("git+https", "git+ssh")):
if str(source).startswith(('git+https', 'git+ssh')):
return 'git'
raise ValueError(
"failed to determine source type for '{0}'".format(source),
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