Show
Ignore:
Timestamp:
12/17/09 14:02:26 (2 years ago)
Author:
Menno Smits <menno@…>
Branch:
default
Message:

core parts of fetch parsing done, lots more tests parsing

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • imapclient/test/test_response_parser.py

    r109 r111  
    3838        self._test('FOO', 'FOO') 
    3939        self._test('F.O:-O_0;', 'F.O:-O_0;') 
     40        self._test(r'\Seen', r'\Seen') 
    4041 
    4142    def test_string(self): 
     
    129130    return dt.astimezone(system_offset).replace(tzinfo=None) 
    130131 
     132 
    131133class TestParseFetchResponse(unittest.TestCase): 
    132134 
    133135    def test_basic(self): 
    134136        self.assertEquals(parse_fetch_response('* 4 FETCH ()'), {4: {}}) 
    135  
    136  
    137     def test_simple_pair(self): 
    138         self.assertEquals(parse_fetch_response('* 23 FETCH (ABC 123 STUFF "hello")'), 
    139                           {'23': {'ABC': 123, 
    140                                   'STUFF': 'hello'}}) 
     137        self.assertEquals(parse_fetch_response('* 4 fEtCh ()'), {4: {}}) 
    141138 
    142139 
     
    149146 
    150147 
     148    def test_bad_data(self): 
     149        self.assertRaises(ParseError, parse_fetch_response, '* 2 FETCH WHAT') 
     150 
     151 
     152    def test_simple_pairs(self): 
     153        self.assertEquals(parse_fetch_response('* 23 FETCH (ABC 123 StUfF "hello")'), 
     154                          {23: {'ABC': 123, 
     155                                'STUFF': 'hello'}}) 
     156 
     157 
     158    def test_odd_pairs(self): 
     159        self.assertRaises(ParseError, parse_fetch_response, '* 2 FETCH (ONE)') 
     160        self.assertRaises(ParseError, parse_fetch_response, '* 2 FETCH (ONE TWO THREE)') 
     161 
     162 
    151163    def test_UID(self): 
    152164        self.assertEquals(parse_fetch_response('* 23 FETCH (UID 76)'), 
    153                           {'76': {}}) 
    154  
     165                          {76: {}}) 
     166        self.assertEquals(parse_fetch_response('* 23 FETCH (uiD 76)'), 
     167                          {76: {}}) 
     168 
     169 
     170    def test_bad_UID(self): 
     171        self.assertRaises(ParseError, parse_fetch_response, '* 2 FETCH (UID X)') 
     172         
    155173 
    156174    def test_FLAGS(self): 
     175        self.assertEquals(parse_fetch_response('* 23 FETCH (FLAGS (\Seen Stuff))'), 
     176                          {23: {'FLAGS': (r'\Seen', 'Stuff')}}) 
     177 
     178 
     179    def test_multiple_messages(self): 
    157180        self.fail() 
     181 
    158182 
    159183    def test_INTERNALDATE(self): 
     
    181205#         dt = check(' 9-Dec-2007 17:08:08 +0000', 
    182206#                    datetime.datetime(2007, 12, 9, 17, 8, 8, 0, FixedOffset(0))) 
    183  
    184     def test_multiple_fields(self): 
    185         self.fail() 
    186  
    187     def test_multiple_messages(self): 
    188         self.fail() 
    189  
    190     def test_case_handling(self): 
    191         self.fail() 
    192 #         self._parse_test( 
    193 #             [r'2 (flaGS (\Deleted Foo \Seen))'], 
    194 #             {2: {'FLAGS': [r'\Deleted', 'Foo', r'\Seen']}} 
    195 #             ) 
    196  
    197  
    198     def test_invalid(self): 
    199         self.fail() 
    200 #         self.assertRaises(ValueError, self.p, [r'2 (FLAGS (\Deleted) MORE)']) 
    201 #         self.assertRaises(ValueError, 
    202 #                 self.t.process_pairs, 'FOO 123 BAH "abc" WHAT?') 
    203 #         self.assertRaises(ValueError, 
    204 #                 self.t.process_pairs, 'HMMM FOO 123 BAH "abc"') 
    205 #         self.assertRaises(ValueError, 
    206 #                 self.t.process_pairs, 'FOO 123 BAD BAH "abc"') 
    207  
    208 #TODO convert the following are mainly FETCH specific tests 
    209  
    210 #     def test_INTERNALDATE(self): 
    211207 
    212208