update smtp returner unit tests

This commit is contained in:
Justin Findlay 2015-05-11 00:23:28 -06:00
parent 7e4198e01e
commit 0d8f865c9f

View File

@ -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__':