Merge "Skip notifications about WIP changes"
This commit is contained in:
commit
e3bcd8a4e9
@ -301,9 +301,15 @@ class Gerrit(threading.Thread):
|
||||
return ret
|
||||
|
||||
def _read(self, data):
|
||||
# We skip notifications abour WIP changes
|
||||
if 'change' in data and data['change'].get('wip', False):
|
||||
self.log.debug('Skipped processing event on WIP change: %s', data)
|
||||
return
|
||||
try:
|
||||
# We only consider event (not project/branch) filters for these.
|
||||
event_only_types = ('ref-updated',)
|
||||
# 'wip-state-changed' is included in order to notify when a change
|
||||
# moves from wip to non-wip.
|
||||
event_only_types = ('ref-updated', 'wip-state-changed')
|
||||
if data['type'] in event_only_types:
|
||||
channel_set = self._channels_for('events', data['type'])
|
||||
else:
|
||||
|
@ -12,6 +12,7 @@
|
||||
# under the License.
|
||||
|
||||
import collections
|
||||
import copy
|
||||
|
||||
import testtools
|
||||
import yaml
|
||||
@ -140,6 +141,9 @@ class GerritTestCase(testtools.TestCase):
|
||||
|
||||
}
|
||||
|
||||
self.sample_data_wip = copy.deepcopy(self.sample_data)
|
||||
self.sample_data_wip['change']['wip'] = True
|
||||
|
||||
def _validate_patchset_created(self):
|
||||
self.assertEqual(1, len(self.ircbot.messages))
|
||||
message = self.ircbot.messages[0]
|
||||
@ -172,6 +176,10 @@ class GerritTestCase(testtools.TestCase):
|
||||
self.gerrit._read(dict(self.sample_data, type='ref-updated'))
|
||||
self._validate_ref_updated()
|
||||
|
||||
def test__read_ref_updated_wip(self):
|
||||
self.gerrit._read(dict(self.sample_data_wip, type='ref-updated'))
|
||||
self.assertEqual(0, len(self.ircbot.messages))
|
||||
|
||||
def _validate_change_merged(self):
|
||||
self.assertEqual(1, len(self.ircbot.messages))
|
||||
message = self.ircbot.messages[0]
|
||||
|
10
tox.ini
10
tox.ini
@ -1,5 +1,8 @@
|
||||
[tox]
|
||||
envlist = py37,pep8
|
||||
envlist =
|
||||
pep8
|
||||
py3
|
||||
py3-{devel}
|
||||
|
||||
[testenv]
|
||||
usedevelop = True
|
||||
@ -11,7 +14,10 @@ setenv = VIRTUAL_ENV={envdir}
|
||||
LC_ALL=en_US.UTF-8
|
||||
PYTHONWARNINGS=default::DeprecationWarning
|
||||
TESTS_DIR=./gerritbot/tests/unit/
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
deps =
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
devel: git+https://opendev.org/opendev/gerritlib.git@master#egg=gerritlib
|
||||
|
||||
whitelist_externals = rm
|
||||
commands =
|
||||
rm -f .testrepository/times.dbm
|
||||
|
Loading…
Reference in New Issue
Block a user