[Checkins] Re: SVN: zope.sendmail/trunk/src/zope/sendmail/ merging
Baiju M
mbaiju at zeomega.com
Mon Aug 20 08:10:00 EDT 2007
Andreas Jung wrote:
>
>
> --On 20. August 2007 09:37:21 +0200 Philipp von Weitershausen
> <philipp at weitershausen.de> wrote:
>
>> Baiju M wrote:
>>> Andreas Jung wrote:
>>>> Log message for revision 79001:
>>>> merging
>>>>
>>>> svn+ssh://svn.zope.org/repos/main/zope.sendmail/branches/ajung-encrypti
>>>>
>>>> on-branch
>>>>
>>>> This branch provides TLS/SSL encryption support.
>>> There are two errors from zope.sendmail, like:
>>> Error in test test_send
>>> (zope.sendmail.tests.test_mailer.TestSMTPMailer)
>>> Traceback (most recent call last):
>>> File "/baiju/usr//lib/python2.4/unittest.py", line 260, in run
>>> testMethod()
>>> File
>>> "/home/baiju/wa/zope.sendmail/src/zope/sendmail/tests/test_mailer.py",
>>> line 68, in test_send
>>> self.mailer.send(fromaddr, toaddrs, msgtext)
>>> File "/home/baiju/wa/zope.sendmail/src/zope/sendmail/mailer.py", line
>>> 49, in send
>>> code, response = connection.ehlo()
>>> AttributeError: 'SMTP' object has no attribute 'ehlo'
>>>
>>> Please modify SMTP mock object to run the test. I just tried to do
>>> this and it's working, please verify it:
>>> ...
>>
>> Also, this features lacks tests of its own. Andreas, could you please
>> fix
>> the existing tests and provide tests for the new feature?
>>
>
> Fixed. But keep in mind that such mock tests are highly artificial and
> can never replace real-world tests (in this case against existing SMTP
> servers).
How to write automated real-world tests ? Is zc.ngi an option ?
Using the mock test at least we can improve test coverage, is it?
Here is the current test coverage for send method:
1: def send(self, fromaddr, toaddrs, message):
3: connection = self.smtp(self.hostname, str(self.port))
# send EHLO
3: code, response = connection.ehlo()
3: if code < 200 or code >300:
>>>>>> raise RuntimeError('Error sending EHLO to the SMTP
server '
'(code=%s, response=%s)' % (code,
response))
# encryption support
3: have_tls = connection.has_extn('starttls')
3: if not have_tls and self.force_tls:
>>>>>> raise RuntimeError('TLS is not available but TLS is
required')
3: if have_tls and have_ssl and not self.no_tls:
>>>>>> connection.starttls()
>>>>>> connection.ehlo()
3: if connection.does_esmtp:
3: if self.username is not None and self.password is not
None:
1: connection.login(self.username, self.password)
>>>>>> elif self.username:
>>>>>> raise RuntimeError('Mailhost does not support ESMTP
but a username '
'is configured')
3: connection.sendmail(fromaddr, toaddrs, message)
3: connection.quit()
Regards,
Baiju M
More information about the Checkins
mailing list