Skip to content

Commit

Permalink
unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre Tardy <pierre.tardy@intel.com>
  • Loading branch information
Pierre Tardy authored and Mikhail Sobolev committed May 25, 2015
1 parent e4d5d7d commit ca8ebbe
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion master/buildbot/test/unit/test_changes_filter.py
Expand Up @@ -18,15 +18,24 @@
from twisted.trial import unittest

from buildbot.changes import filter
from buildbot.process.properties import Properties
from buildbot.test.fake.state import State


class Change(State):

def __init__(self, **kw):
State.__init__(self, **kw)
# change.properties is a IProperties
props = Properties()
props.update(self.properties, "test")
self.properties = props
project = ''
repository = ''
branch = ''
category = ''
codebase = ''
properties = {}


class ChangeFilter(unittest.TestCase):
Expand Down Expand Up @@ -112,7 +121,7 @@ def test_filter_change_combination(self):
self.no(Change(project='p', repository='r', branch='b', category='x'),
"three match -> False")
self.no(Change(project='p', repository='r', branch='b', category='c',
codebase='x'), "four match -> False")
codebase='x'), "four match -> False")
self.yes(Change(project='p', repository='r', branch='b', category='c',
codebase='cb'), "all match -> True")
self.check()
Expand All @@ -129,3 +138,14 @@ def test_filter_change_combination_filter_fn(self):
self.yes(Change(project='p', repository='r', branch='b', category='c', ff=True),
"all match and fn returns True -> False")
self.check()

def test_filter_props(self):
self.setfilter()
self.filt.checks.update(
self.filt.createChecks(
("ref-updated", None, None, "prop:event.type"),
))
self.yes(Change(properties={'event.type': 'ref-updated'}), "matching property")
self.no(Change(properties={'event.type': 'patch-uploaded'}), "non matching property")
self.no(Change(properties={}), "no property")
self.check()

0 comments on commit ca8ebbe

Please sign in to comment.