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:
parent
28c3bc6268
commit
390dff52ae
@ -45,6 +45,23 @@ class PungiNotifier(object):
|
|||||||
self.compose, self.compose.paths.compose.topdir())
|
self.compose, self.compose.paths.compose.topdir())
|
||||||
data.setdefault('location', location)
|
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):
|
def send(self, msg, workdir=None, **kwargs):
|
||||||
"""Send a message.
|
"""Send a message.
|
||||||
|
|
||||||
|
@ -30,7 +30,22 @@ class TestNotifier(unittest.TestCase):
|
|||||||
self.logfile = '/logs/notifications/notification-2017-06-28_09-34-00.log'
|
self.logfile = '/logs/notifications/notification-2017-06-28_09-34-00.log'
|
||||||
self.compose = mock.Mock(
|
self.compose = mock.Mock(
|
||||||
compose_id='COMPOSE_ID',
|
compose_id='COMPOSE_ID',
|
||||||
|
compose_date='20171031',
|
||||||
|
compose_respin=1,
|
||||||
|
compose_label='Updates-20171031.1021',
|
||||||
|
compose_type='production',
|
||||||
log_warning=mock.Mock(),
|
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(
|
paths=mock.Mock(
|
||||||
compose=mock.Mock(
|
compose=mock.Mock(
|
||||||
topdir=mock.Mock(return_value='/a/b')
|
topdir=mock.Mock(return_value='/a/b')
|
||||||
@ -46,6 +61,19 @@ class TestNotifier(unittest.TestCase):
|
|||||||
data = self.data.copy()
|
data = self.data.copy()
|
||||||
data['compose_id'] = 'COMPOSE_ID'
|
data['compose_id'] = 'COMPOSE_ID'
|
||||||
data['location'] = '/a/b'
|
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)
|
data.update(kwargs)
|
||||||
return mock.call((script, cmd),
|
return mock.call((script, cmd),
|
||||||
stdin_data=json.dumps(data),
|
stdin_data=json.dumps(data),
|
||||||
@ -84,9 +112,7 @@ class TestNotifier(unittest.TestCase):
|
|||||||
@mock.patch('kobo.shortcuts.run')
|
@mock.patch('kobo.shortcuts.run')
|
||||||
def test_translates_path(self, run, makedirs):
|
def test_translates_path(self, run, makedirs):
|
||||||
self.compose.paths.compose.topdir.return_value = '/root/a/b'
|
self.compose.paths.compose.topdir.return_value = '/root/a/b'
|
||||||
self.compose.conf = {
|
self.compose.conf["translate_paths"] = [("/root/", "http://example.com/compose/")]
|
||||||
"translate_paths": [("/root/", "http://example.com/compose/")],
|
|
||||||
}
|
|
||||||
|
|
||||||
run.return_value = (0, None)
|
run.return_value = (0, None)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user