)
)
- envelope_str = ('1 (ENVELOPE ( '
- 'NIL '
- '"subject" '
- '(("name" NIL "address1" "domain1.com")) '
- '((NIL NIL "address2" "domain2.com")) '
- '(("name" NIL "address3" "domain3.com")) '
- 'NIL'
- '((NIL NIL "address4" "domain4.com") '
- '("person" NIL "address4b" "domain4b.com")) '
- 'NIL "<reply-to-id>" "<msg_id>"))')
+ def test_ENVELOPE_with_no_date(self):
- self.assertSequenceEqual(output[1]['ENVELOPE'],
++ envelope_str = (b'1 (ENVELOPE ( '
++ b'NIL '
++ b'"subject" '
++ b'(("name" NIL "address1" "domain1.com")) '
++ b'((NIL NIL "address2" "domain2.com")) '
++ b'(("name" NIL "address3" "domain3.com")) '
++ b'NIL'
++ b'((NIL NIL "address4" "domain4.com") '
++ b'("person" NIL "address4b" "domain4b.com")) '
++ b'NIL "<reply-to-id>" "<msg_id>"))')
+
+ output = parse_fetch_response([envelope_str], normalise_times=False)
+
- "subject",
- (Address("name", None, "address1", "domain1.com"),),
- (Address(None, None, "address2", "domain2.com"),),
- (Address("name", None, "address3", "domain3.com"),),
++ self.assertSequenceEqual(output[1][b'ENVELOPE'],
+ Envelope(
+ None,
- (Address(None, None, "address4", "domain4.com"),
- Address("person", None, "address4b", "domain4b.com")),
- None, "<reply-to-id>", "<msg_id>"
++ b"subject",
++ (Address(b"name", None, b"address1", b"domain1.com"),),
++ (Address(None, None, b"address2", b"domain2.com"),),
++ (Address(b"name", None, b"address3", b"domain3.com"),),
+ None,
- def test_INTERNALDATE_normalised(self):
++ (Address(None, None, b"address4", b"domain4.com"),
++ Address(b"person", None, b"address4b", b"domain4b.com")),
++ None, b"<reply-to-id>", b"<msg_id>"
+ )
+ )
++
+ def test_INTERNALDATE(self):
def check(date_str, expected_dt):
- output = parse_fetch_response(['3 (INTERNALDATE "%s")' % date_str])
- actual_dt = output[3]['INTERNALDATE']
- self.assertTrue(actual_dt.tzinfo is None) # Returned date should be in local timezone
- expected_dt = datetime_to_native(expected_dt)
+ output = parse_fetch_response([b'3 (INTERNALDATE "' + date_str + b'")'], normalise_times=False)
+ actual_dt = output[3][b'INTERNALDATE']
self.assertEqual(actual_dt, expected_dt)
- check(' 9-Feb-2007 17:08:08 -0430',
+ check(b' 9-Feb-2007 17:08:08 -0430',
datetime(2007, 2, 9, 17, 8, 8, 0, FixedOffset(-4*60 - 30)))
-
- check('12-Feb-2007 17:08:08 +0200',
+
+ check(b'12-Feb-2007 17:08:08 +0200',
datetime(2007, 2, 12, 17, 8, 8, 0, FixedOffset(2*60)))
-
- check(' 9-Dec-2007 17:08:08 +0000',
+
+ check(b' 9-Dec-2007 17:08:08 +0000',
datetime(2007, 12, 9, 17, 8, 8, 0, FixedOffset(0)))
- def test_INTERNALDATE(self):
+ def test_INTERNALDATE_normalised(self):
def check(date_str, expected_dt):
- output = parse_fetch_response(['3 (INTERNALDATE "%s")' % date_str], normalise_times=False)
- actual_dt = output[3]['INTERNALDATE']
+ output = parse_fetch_response([b'3 (INTERNALDATE "' + date_str + b'")'])
+ actual_dt = output[3][b'INTERNALDATE']
+ self.assertTrue(actual_dt.tzinfo is None) # Returned date should be in local timezone
+ expected_dt = datetime_to_native(expected_dt)
self.assertEqual(actual_dt, expected_dt)
- check(' 9-Feb-2007 17:08:08 -0430',
+ check(b' 9-Feb-2007 17:08:08 -0430',
datetime(2007, 2, 9, 17, 8, 8, 0, FixedOffset(-4*60 - 30)))
-
- check('12-Feb-2007 17:08:08 +0200',
+
+ check(b'12-Feb-2007 17:08:08 +0200',
datetime(2007, 2, 12, 17, 8, 8, 0, FixedOffset(2*60)))
-
- check(' 9-Dec-2007 17:08:08 +0000',
+
+ check(b' 9-Dec-2007 17:08:08 +0000',
datetime(2007, 12, 9, 17, 8, 8, 0, FixedOffset(0)))
def test_mixed_types(self):