notification: Add more info into the messages

Fixes: https://pagure.io/pungi/issue/771
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2017-10-31 10:47:01 +01:00
parent 28c3bc6268
commit 390dff52ae
2 changed files with 46 additions and 3 deletions

View File

@ -45,6 +45,23 @@ class PungiNotifier(object):
self.compose, self.compose.paths.compose.topdir())
data.setdefault('location', location)
# Add information about the compose itself.
data.setdefault('compose_date', self.compose.compose_date)
data.setdefault('compose_type', self.compose.compose_type)
data.setdefault('compose_respin', self.compose.compose_respin)
data.setdefault('compose_label', self.compose.compose_label)
data.setdefault('release_short', self.compose.conf['release_short'])
data.setdefault('release_name', self.compose.conf['release_name'])
data.setdefault('release_version', self.compose.conf['release_version'])
data.setdefault('release_type', self.compose.conf['release_type'].lower())
data.setdefault('release_is_layered', self.compose.conf["release_is_layered"])
if self.compose.conf['release_is_layered']:
data['base_product_name'] = self.compose.conf["base_product_name"]
data['base_product_version'] = self.compose.conf["base_product_version"]
data['base_product_short'] = self.compose.conf["base_product_short"]
data['base_product_type'] = self.compose.conf["base_product_type"].lower()
def send(self, msg, workdir=None, **kwargs):
"""Send a message.

View File

@ -30,7 +30,22 @@ class TestNotifier(unittest.TestCase):
self.logfile = '/logs/notifications/notification-2017-06-28_09-34-00.log'
self.compose = mock.Mock(
compose_id='COMPOSE_ID',
compose_date='20171031',
compose_respin=1,
compose_label='Updates-20171031.1021',
compose_type='production',
log_warning=mock.Mock(),
conf={
'release_name': 'Layer',
'release_short': 'L',
'release_version': '27',
'release_type': 'updates',
'release_is_layered': True,
'base_product_name': 'Base',
'base_product_short': 'B',
'base_product_version': '1',
'base_product_type': 'ga',
},
paths=mock.Mock(
compose=mock.Mock(
topdir=mock.Mock(return_value='/a/b')
@ -46,6 +61,19 @@ class TestNotifier(unittest.TestCase):
data = self.data.copy()
data['compose_id'] = 'COMPOSE_ID'
data['location'] = '/a/b'
data['compose_date'] = '20171031'
data['compose_type'] = 'production'
data['compose_respin'] = 1
data['compose_label'] = 'Updates-20171031.1021'
data['release_short'] = 'L'
data['release_name'] = 'Layer'
data['release_version'] = '27'
data['release_type'] = 'updates'
data['release_is_layered'] = True
data['base_product_name'] = 'Base'
data['base_product_version'] = '1'
data['base_product_short'] = 'B'
data['base_product_type'] = 'ga'
data.update(kwargs)
return mock.call((script, cmd),
stdin_data=json.dumps(data),
@ -84,9 +112,7 @@ class TestNotifier(unittest.TestCase):
@mock.patch('kobo.shortcuts.run')
def test_translates_path(self, run, makedirs):
self.compose.paths.compose.topdir.return_value = '/root/a/b'
self.compose.conf = {
"translate_paths": [("/root/", "http://example.com/compose/")],
}
self.compose.conf["translate_paths"] = [("/root/", "http://example.com/compose/")]
run.return_value = (0, None)