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("gwkoji.build.find_executable", return_value="/usr/bin/spectool")
@mock.patch("gwkoji.build.logged_check_call")
@mock.patch('gwkoji.build.find_executable', return_value='/usr/bin/spectool')
@mock.patch('gwkoji.build.logged_check_call')
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)
call.assert_called_once_with(
["/usr/bin/spectool", "--get-files", "--directory",
"outdir", "test.spec"],
['/usr/bin/spectool', '--get-files', '--directory',
'outdir', 'test.spec'],
logger=1,
)
......
......@@ -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):
gwkoji_options.parse_options()
......@@ -25,12 +25,13 @@ from .. import utils as gwkoji_utils
@pytest.mark.parametrize("source, type_", [
("git+https://git.ligo.org/albert/gr", "git"),
("mypackage.spec", "spec"),
("mypackage.src.rpm", "srcrpm"),
("mypackage.tar", "tarball"),
("mypackage.tar.gz", "tarball"),
("mypackage.tar.xz", "tarball"),
('git+https://git.ligo.org/albert/gr#origin/rhel', '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):
gwkoji_utils.source_type("blah")
gwkoji_utils.source_type('blah')
......@@ -77,13 +77,13 @@ def source_type(source):
"""
source = pathlib.Path(source)
name = 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