Fix journald unittests

d7df072b96 changed how we call
journal.send() from positional arguments to keyword arguments.  So we
need to update the test to check for the arguments it was called with in
the keyword args, not in the positional args.
This commit is contained in:
Toshio Kuratomi 2018-07-25 10:45:51 -07:00
parent dbff49dee0
commit 5b4a7cc283

View file

@ -120,7 +120,7 @@ class TestAnsibleModuleLogJournal:
assert journal_send.called == 1
# Message
# call_args is a 2-tuple of (arg_list, kwarg_dict)
assert journal_send.call_args[0][0].endswith('unittest no_log'), 'Message was not sent to log'
assert journal_send.call_args[1]['MESSAGE'].endswith('unittest no_log'), 'Message was not sent to log'
# log adds this journal field
assert 'MODULE' in journal_send.call_args[1]
assert 'basic.py' in journal_send.call_args[1]['MODULE']
@ -133,14 +133,14 @@ class TestAnsibleModuleLogJournal:
journal_send = mocker.patch('systemd.journal.send')
am.log(msg)
assert journal_send.call_count == 1, 'journal.send not called exactly once'
assert journal_send.call_args[0][0].endswith(param)
assert journal_send.call_args[1]['MESSAGE'].endswith(param)
@pytest.mark.parametrize('stdin', ({},), indirect=['stdin'])
def test_log_args(self, am, mocker):
journal_send = mocker.patch('systemd.journal.send')
am.log('unittest log_args', log_args=dict(TEST='log unittest'))
assert journal_send.called == 1
assert journal_send.call_args[0][0].endswith('unittest log_args'), 'Message was not sent to log'
assert journal_send.call_args[1]['MESSAGE'].endswith('unittest log_args'), 'Message was not sent to log'
# log adds this journal field
assert 'MODULE' in journal_send.call_args[1]