stub kojid tests
This commit is contained in:
parent
144a4f1b30
commit
695ded30c8
3 changed files with 54 additions and 0 deletions
0
tests/test_builder/__init__.py
Normal file
0
tests/test_builder/__init__.py
Normal file
13
tests/test_builder/loadkojid.py
Normal file
13
tests/test_builder/loadkojid.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
# http://stackoverflow.com/questions/67631/how-to-import-a-module-given-the-full-path
|
||||
KOJID_FILENAME = os.path.dirname(__file__) + "/../../builder/kojid"
|
||||
if sys.version_info[0] >= 3:
|
||||
import importlib.util
|
||||
spec = importlib.util.spec_from_file_location("koji_kojid", KOJID_FILENAME)
|
||||
kojid = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(kojid)
|
||||
else:
|
||||
import imp
|
||||
kojid = imp.load_source('koji_kojid', KOJID_FILENAME)
|
||||
41
tests/test_builder/test_choose_taskarch.py
Normal file
41
tests/test_builder/test_choose_taskarch.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import unittest
|
||||
import os
|
||||
import sys
|
||||
import mock
|
||||
import rpm
|
||||
import tempfile
|
||||
|
||||
from loadkojid import kojid
|
||||
|
||||
|
||||
class FakeHeader(dict):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
for key in kwargs:
|
||||
kname = "RPMTAG_%s" % key.upper()
|
||||
hkey = getattr(rpm, kname)
|
||||
self.__setitem__(hkey, kwargs[key])
|
||||
|
||||
|
||||
class TestChooseTaskarch(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
task_id = 99
|
||||
method = 'build'
|
||||
params = []
|
||||
self.session = mock.MagicMock()
|
||||
self.options = mock.MagicMock()
|
||||
workdir = tempfile.mkdtemp()
|
||||
self.handler = kojid.BuildTask(task_id, method, params, self.session,
|
||||
self.options, workdir)
|
||||
self.readSRPMHeader = mock.MagicMock()
|
||||
self.handler.readSRPMHeader = self.readSRPMHeader
|
||||
|
||||
def test_noarch(self):
|
||||
self.readSRPMHeader.return_value = FakeHeader(buildarchs=['noarch'],
|
||||
exclusivearch=[], excludearch=[])
|
||||
self.handler.choose_taskarch('noarch', 'srpm', 'build_tag')
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue