bd8d814230
The messaging is not really part of compose settings. It is an infrastructure part. As such, it should really be set up as part of pungi invocation, not compose configuration. The documentation is updated to reflect this. Some updates to the documentation are done as well: listing messages about ISOs and minor formatting updates. The test_compose.sh script can now accept additional command line options and pass them on to pungi-koji to simplify testing. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
71 lines
2.0 KiB
Python
Executable File
71 lines
2.0 KiB
Python
Executable File
#!/usr/bin/python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import json
|
|
import mock
|
|
import os
|
|
import sys
|
|
import unittest
|
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
|
|
|
from pungi.notifier import PungiNotifier
|
|
|
|
|
|
class TestNotifier(unittest.TestCase):
|
|
@mock.patch('kobo.shortcuts.run')
|
|
def test_invokes_script(self, run):
|
|
compose = mock.Mock(
|
|
compose_id='COMPOSE_ID',
|
|
paths=mock.Mock(
|
|
compose=mock.Mock(
|
|
topdir=mock.Mock(return_value='/a/b')
|
|
)
|
|
)
|
|
)
|
|
|
|
run.return_value = (0, None)
|
|
|
|
n = PungiNotifier('run-notify')
|
|
n.compose = compose
|
|
data = {'foo': 'bar', 'baz': 'quux'}
|
|
n.send('cmd', **data)
|
|
|
|
data['compose_id'] = 'COMPOSE_ID'
|
|
run.assert_called_once_with(('run-notify', 'cmd'),
|
|
stdin_data=json.dumps(data),
|
|
can_fail=True, return_stdout=False, workdir='/a/b')
|
|
|
|
@mock.patch('kobo.shortcuts.run')
|
|
def test_does_not_run_without_config(self, run):
|
|
n = PungiNotifier(None)
|
|
n.send('cmd', foo='bar', baz='quux')
|
|
self.assertFalse(run.called)
|
|
|
|
@mock.patch('kobo.shortcuts.run')
|
|
def test_logs_warning_on_failure(self, run):
|
|
compose = mock.Mock(
|
|
compose_id='COMPOSE_ID',
|
|
log_warning=mock.Mock(),
|
|
paths=mock.Mock(
|
|
compose=mock.Mock(
|
|
topdir=mock.Mock(return_value='/a/b')
|
|
)
|
|
)
|
|
)
|
|
|
|
run.return_value = (1, None)
|
|
|
|
n = PungiNotifier('run-notify')
|
|
n.compose = compose
|
|
n.send('cmd')
|
|
|
|
run.assert_called_once_with(('run-notify', 'cmd'),
|
|
stdin_data=json.dumps({'compose_id': 'COMPOSE_ID'}),
|
|
can_fail=True, return_stdout=False, workdir='/a/b')
|
|
self.assertTrue(compose.log_warning.called)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|