mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
update smtp returner unit tests
This commit is contained in:
parent
7e4198e01e
commit
0d8f865c9f
@ -45,8 +45,19 @@ class SMTPReturnerTestCase(TestCase):
|
||||
'jid': '54321',
|
||||
'return': 'The room is on fire as shes fixing her hair'
|
||||
}
|
||||
options = {'username': '',
|
||||
'tls': '',
|
||||
'from': '',
|
||||
'fields': 'id,fun,fun_args,jid,return',
|
||||
'to': '',
|
||||
'host': '',
|
||||
'renderer': 'yaml',
|
||||
'template': '',
|
||||
'password': '',
|
||||
'gpgowner': '',
|
||||
'subject': ''}
|
||||
|
||||
with patch.dict(smtp.__salt__, {'config.option': MagicMock()}):
|
||||
with patch('salt.returners.smtp_return._get_options', MagicMock(return_value=options)):
|
||||
smtp.returner(ret)
|
||||
self.assertTrue(mocked_smtplib.return_value.sendmail.called)
|
||||
|
||||
@ -54,12 +65,16 @@ if HAS_GNUPG:
|
||||
@patch('salt.returners.smtp_return.gnupg')
|
||||
@patch('salt.returners.smtp_return.smtplib.SMTP')
|
||||
def test_returner(self, mocked_smtplib, *args):
|
||||
self._test_returner(mocked_smtplib, *args)
|
||||
with patch.dict(smtp.__opts__, {'extension_modules': '',
|
||||
'renderer': 'yaml'}):
|
||||
self._test_returner(mocked_smtplib, *args)
|
||||
|
||||
else:
|
||||
@patch('salt.returners.smtp_return.smtplib.SMTP')
|
||||
def test_returner(self, mocked_smtplib, *args):
|
||||
self._test_returner(mocked_smtplib, *args)
|
||||
with patch.dict(smtp.__opts__, {'extension_modules': '',
|
||||
'renderer': 'yaml'}):
|
||||
self._test_returner(mocked_smtplib, *args)
|
||||
|
||||
SMTPReturnerTestCase.test_returner = test_returner
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
Reference in New Issue
Block a user