MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_dsn

Method test_dsn

Lib/test/test_email/test_email.py:2647–2702  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2645 eq(submsg.get_payload(), 'Here is the body of the message.\n')
2646
2647 def test_dsn(self):
2648 eq = self.assertEqual
2649 # msg 16 is a Delivery Status Notification, see RFC 1894
2650 msg = self._msgobj('msg_16.txt')
2651 eq(msg.get_content_type(), 'multipart/report')
2652 self.assertTrue(msg.is_multipart())
2653 eq(len(msg.get_payload()), 3)
2654 # Subpart 1 is a text/plain, human readable section
2655 subpart = msg.get_payload(0)
2656 eq(subpart.get_content_type(), 'text/plain')
2657 eq(subpart.get_payload(), """\
2658This report relates to a message you sent with the following header fields:
2659
2660 Message-id: <002001c144a6$8752e060$56104586@oxy.edu>
2661 Date: Sun, 23 Sep 2001 20:10:55 -0700
2662 From: "Ian T. Henry" <henryi@oxy.edu>
2663 To: SoCal Raves <scr@socal-raves.org>
2664 Subject: [scr] yeah for Ians!!
2665
2666Your message cannot be delivered to the following recipients:
2667
2668 Recipient address: jangel1@cougar.noc.ucla.edu
2669 Reason: recipient reached disk quota
2670
2671""")
2672 # Subpart 2 contains the machine parsable DSN information. It
2673 # consists of two blocks of headers, represented by two nested Message
2674 # objects.
2675 subpart = msg.get_payload(1)
2676 eq(subpart.get_content_type(), 'message/delivery-status')
2677 eq(len(subpart.get_payload()), 2)
2678 # message/delivery-status should treat each block as a bunch of
2679 # headers, i.e. a bunch of Message objects.
2680 dsn1 = subpart.get_payload(0)
2681 self.assertIsInstance(dsn1, Message)
2682 eq(dsn1['original-envelope-id'], '0GK500B4HD0888@cougar.noc.ucla.edu')
2683 eq(dsn1.get_param('dns', header='reporting-mta'), '')
2684 # Try a missing one <wink>
2685 eq(dsn1.get_param('nsd', header='reporting-mta'), None)
2686 dsn2 = subpart.get_payload(1)
2687 self.assertIsInstance(dsn2, Message)
2688 eq(dsn2['action'], 'failed')
2689 eq(dsn2.get_params(header='original-recipient'),
2690 [('rfc822', ''), ('jangel1@cougar.noc.ucla.edu', '')])
2691 eq(dsn2.get_param('rfc822', header='final-recipient'), '')
2692 # Subpart 3 is the original message
2693 subpart = msg.get_payload(2)
2694 eq(subpart.get_content_type(), 'message/rfc822')
2695 payload = subpart.get_payload()
2696 self.assertIsInstance(payload, list)
2697 eq(len(payload), 1)
2698 subsubpart = payload[0]
2699 self.assertIsInstance(subsubpart, Message)
2700 eq(subsubpart.get_content_type(), 'text/plain')
2701 eq(subsubpart['message-id'],
2702 '<002001c144a6$8752e060$56104586@oxy.edu>')
2703
2704 def test_epilogue(self):

Callers

nothing calls this directly

Calls 10

lenFunction · 0.85
get_content_typeMethod · 0.80
assertTrueMethod · 0.80
is_multipartMethod · 0.80
get_payloadMethod · 0.80
assertIsInstanceMethod · 0.80
get_paramMethod · 0.80
get_paramsMethod · 0.80
eqFunction · 0.50
_msgobjMethod · 0.45

Tested by

no test coverage detected