From: W. Trevor King Date: Sat, 1 Sep 2012 12:08:40 +0000 (-0400) Subject: handler:submission: add doctest to run(). X-Git-Tag: v0.3~45 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=cf2327b19d847809b8276c0576d5084c0c157d31;p=pygrader.git handler:submission: add doctest to run(). --- diff --git a/pygrader/handler/submission.py b/pygrader/handler/submission.py index 0946c10..7011f55 100644 --- a/pygrader/handler/submission.py +++ b/pygrader/handler/submission.py @@ -24,6 +24,79 @@ from . import respond as _respond def run(basedir, course, original, message, person, subject, max_late=0, respond=None, use_color=None, dry_run=None): + """ + >>> from pgp_mime.email import encodedMIMEText + >>> from pygrader.test.course import StubCourse + >>> course = StubCourse() + >>> person = list( + ... course.course.find_people(email='bb@greyhavens.net'))[0] + >>> message = encodedMIMEText('The answer is 42.') + >>> message['Message-ID'] = '<123.456@home.net>' + >>> message['Received'] = ( + ... 'from smtp.home.net (smtp.home.net [123.456.123.456]) ' + ... 'by smtp.mail.uu.edu (Postfix) with ESMTP id 5BA225C83EF ' + ... 'for ; Sun, 09 Oct 2011 11:50:46 -0400 (EDT)') + >>> subject = '[submit] assignment 1' + >>> def respond(message): + ... print('respond with:\\n{}'.format(message.as_string())) + >>> run(basedir=course.basedir, course=course.course, original=message, + ... message=message, person=person, subject=subject, + ... max_late=0, respond=respond) + ... # doctest: +ELLIPSIS, +REPORT_UDIFF + respond with: + Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha1"; boundary="===============...==" + MIME-Version: 1.0 + Content-Disposition: inline + Date: ... + From: Robot101 + Reply-to: Robot101 + To: Bilbo Baggins + Subject: received Assignment 1 submission + + --===============...== + Content-Type: multipart/mixed; boundary="===============...==" + MIME-Version: 1.0 + + --===============...== + Content-Type: text/plain; charset="us-ascii" + MIME-Version: 1.0 + Content-Transfer-Encoding: 7bit + Content-Disposition: inline + + Billy, + + We received your submission for Assignment 1 on .... + + Yours, + phys-101 robot + --===============...== + Content-Type: message/rfc822 + MIME-Version: 1.0 + + Content-Type: text/plain; charset="us-ascii" + MIME-Version: 1.0 + Content-Transfer-Encoding: 7bit + Content-Disposition: inline + Message-ID: <123.456@home.net> + Received: from smtp.home.net (smtp.home.net [123.456.123.456]) by smtp.mail.uu.edu (Postfix) with ESMTP id 5BA225C83EF for ; Sun, 09 Oct 2011 11:50:46 -0400 (EDT) + + The answer is 42. + --===============...==-- + --===============...== + MIME-Version: 1.0 + Content-Transfer-Encoding: 7bit + Content-Description: OpenPGP digital signature + Content-Type: application/pgp-signature; name="signature.asc"; charset="us-ascii" + + -----BEGIN PGP SIGNATURE----- + Version: GnuPG v2.0.19 (GNU/Linux) + + ... + -----END PGP SIGNATURE----- + + --===============...==-- + >>> course.cleanup() + """ time = _message_time(message=message, use_color=use_color) for assignment in course.assignments: