From: Menno Smits Date: Wed, 13 Aug 2014 11:12:18 +0000 (+1200) Subject: resync with trunk X-Git-Tag: 0.12^2~7^2~18 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=37f8032cad05810746822c472a3065c421d09f11;p=imapclient.git resync with trunk --- 37f8032cad05810746822c472a3065c421d09f11 diff --cc imapclient/test/test_response_parser.py index abfaa06,a4ccb70..33e117c --- a/imapclient/test/test_response_parser.py +++ b/imapclient/test/test_response_parser.py @@@ -351,36 -349,63 +351,64 @@@ class TestParseFetchResponse(unittest.T ) ) + def test_ENVELOPE_with_no_date(self): - 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 "" ""))') ++ 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 "" ""))') + + output = parse_fetch_response([envelope_str], normalise_times=False) + - self.assertSequenceEqual(output[1]['ENVELOPE'], ++ self.assertSequenceEqual(output[1][b'ENVELOPE'], + Envelope( + None, - "subject", - (Address("name", None, "address1", "domain1.com"),), - (Address(None, None, "address2", "domain2.com"),), - (Address("name", None, "address3", "domain3.com"),), ++ 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, - (Address(None, None, "address4", "domain4.com"), - Address("person", None, "address4b", "domain4b.com")), - None, "", "" ++ (Address(None, None, b"address4", b"domain4.com"), ++ Address(b"person", None, b"address4b", b"domain4b.com")), ++ None, b"", b"" + ) + ) - def test_INTERNALDATE_normalised(self): ++ + 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):