Tests failing with 0.17.0
Closed this issue · 2 comments
hydrapolic commented
# py.test
===================================================================================================================================================== test session starts =====================================================================================================================================================
platform linux2 -- Python 2.7.11, pytest-2.8.2, py-1.4.30, pluggy-0.3.1
rootdir: /tmp/jenkins-autojobs-0.17.0, inifile:
plugins: cov-2.2.0
collected 65 items
tests/test_git.py ......................................s
tests/test_hg.py ...........
tests/test_svn.py ..............
tests/test_utils.py F
========================================================================================================================================================== FAILURES ===========================================================================================================================================================
______________________________________________________________________________________________________________________________________________________ test_filter_jobs _______________________________________________________________________________________________________________________________________________________
def test_filter_jobs():
class Job:
def __init__(self, name):
self.name = name
class jenkins:
pass
names = ['feature-one', 'feature-two', 'release-one', 'release-two']
jenkins.jobs = [Job(i) for i in names]
filter_jobs = lambda **kw: {i.name for i in main.filter_jobs(jenkins, **kw)}
#-------------------------------------------------------------------------
assert filter_jobs() == {'feature-one', 'feature-two', 'release-one', 'release-two'}
res = filter_jobs(by_name_regex=[re.compile('feature-')])
assert res == {'feature-one', 'feature-two'}
res = filter_jobs(by_name_regex=[re.compile('.*one'), re.compile('.*two')])
assert res == {'feature-one', 'feature-two', 'release-one', 'release-two'}
#-------------------------------------------------------------------------
view_jobs = {
'v1': [Job('scratch-one'), Job('scratch-two')],
'v2': [Job('release-one'), Job('maintenance-three')]
}
jenkins.view_jobs = lambda x: view_jobs[x]
> res = filter_jobs(by_views=['v1'])
../test_utils.py:36:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../test_utils.py:18: in <lambda>
filter_jobs = lambda **kw: {i.name for i in main.filter_jobs(jenkins, **kw)}
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
jenkins = <class test_utils.jenkins at 0x7f26a5fc8e88>, by_views = ['v1'], by_name_regex = ()
def filter_jobs(jenkins, by_views=(), by_name_regex=()):
'''Select only jobs that belong to a given view or the names of which match a regex.'''
jobs = set()
if not by_views and not by_name_regex:
return jenkins.jobs
# Select jobs in the by_views list.
for view_name in by_views:
> view_jobs = jenkins.view_jobs(view_name)
E TypeError: unbound method <lambda>() must be called with jenkins instance as first argument (got str instance instead)
/usr/lib64/python2.7/site-packages/jenkins_autojobs/main.py:235: TypeError
======================================================================================================================================= 1 failed, 63 passed, 1 skipped in 21.57 seconds =======================================================================================================================================
hydrapolic commented
Thanks @gvalkov