Commit adbfa57d authored by Adam Mercer's avatar Adam Mercer
Browse files

Merge branch 'increase-test-coverage' into 'master'

Increase test coverage

See merge request adam-mercer/koji-packager!5
parents ea1132be e4b14614
......@@ -33,3 +33,22 @@ def test_download_spec_sources(call, _):
"outdir", "test.spec"],
logger=1,
)
@mock.patch('gwkoji.build.find_executable', return_value='/usr/bin/rpmbuild')
def test_rpmbuild_args(_):
args = gwkoji_build._rpmbuild_args(
'-bs', 'foobar-1.0-1.spec', tmpdir='/tmp'
)
assert args == [
'/usr/bin/rpmbuild', '--verbose', '--define', '_topdir /tmp',
'-bs', 'foobar-1.0-1.spec'
]
@mock.patch('gwkoji.build.find_executable', return_value='/usr/bin/rpmbuild')
def test_rpmbuild_args_none(_):
args = gwkoji_build._rpmbuild_args('-bs', 'foobar-1.0-1.spec', tmpdir=None)
assert args == [
'/usr/bin/rpmbuild', '--verbose', '-bs', 'foobar-1.0-1.spec'
]
# -*- coding: utf-8 -*-
# Copyright(C) 2019 Adam Mercer <adam.mercer@ligo.org>
#
# This file is part of gwkoji.
#
# gwkoji is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest
from unittest import mock
from .. import koji as gwkoji_koji
@mock.patch('gwkoji.koji.find_executable', return_value=None)
def test_moshimoshi_errors(_):
with pytest.raises(FileNotFoundError):
gwkoji_koji.moshimoshi(logger=1)
@mock.patch('gwkoji.koji.find_executable', return_value='/usr/bin/koji')
@mock.patch('gwkoji.koji.logged_check_call')
def test_moshimoshi(call, _):
gwkoji_koji.moshimoshi(logger=1)
call.assert_called_once_with(('/usr/bin/koji', 'moshimoshi'), logger=1)
@mock.patch('gwkoji.koji.find_executable', return_value='/usr/bin/koji')
@mock.patch('gwkoji.koji.logged_check_call')
def test_list_pkgs(call, _):
gwkoji_koji.list_pkgs('--quiet', '--package', 'foobar', logger=1)
call.assert_called_once_with(
('/usr/bin/koji', 'list-pkgs', '--quiet', '--package', 'foobar'),
logger=1
)
@mock.patch('gwkoji.koji.find_executable', return_value='/usr/bin/koji')
@mock.patch('gwkoji.koji.logged_check_call')
def test_add_pkg(call, _):
# FIXME: this needs to be updated to automatically pass --owner in the
# appropriate place
gwkoji_koji.add_pkg(
'--owner', 'albert.einstein@LIGO.ORG', 'foobar', logger=1
)
call.assert_called_once_with(
('/usr/bin/koji', 'add-pkg', '--owner',
'albert.einstein@LIGO.ORG', 'foobar'), logger=1
)
@mock.patch('gwkoji.koji.find_executable', return_value='/usr/bin/koji')
@mock.patch('gwkoji.koji.logged_check_call')
def test_build(call, _):
gwkoji_koji.build('sandbox', 'foobar-1.0-1.el7.src.rpm', logger=1)
call.assert_called_once_with(
('/usr/bin/koji', 'build', 'sandbox', 'foobar-1.0-1.el7.src.rpm'),
logger=1
)
......@@ -19,6 +19,7 @@
"""Test suite for gwkoji.rpm
"""
import pytest
from unittest import mock
from .. import rpm as gwkoji_rpm
......@@ -32,3 +33,12 @@ def test_download_spec_sources(call, _):
('/usr/bin/rpm', '--queryformat', '%{NAME}', '-qp',
'foobar-1.0-1.el7'), logger=1,
)
@mock.patch('gwkoji.rpm.find_executable', return_value=None)
def test_function_errors(_):
with pytest.raises(FileNotFoundError):
gwkoji_rpm.get_package_name_from_source_rpm(
'foobar-1.0-1.el7',
logger=1
)
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