示例#1
0
 def test_increments_offset_from(self):
     token = entities.ChunkedResumptionToken(set='',
                                             from_='1998-01-01',
                                             until='1998-12-31',
                                             offset='1998-12-31(1001)',
                                             count='1000',
                                             metadataPrefix='oai_dc')
     self.assertEqual(
         token._incr_offset_from(),
         entities.ChunkedResumptionToken(set='',
                                         from_='1998-01-01',
                                         until='1998-12-31',
                                         offset='1999-01-01(0)',
                                         count='1000',
                                         metadataPrefix='oai_dc'))
示例#2
0
 def test_encode_ommit_empty_strings(self):
     token = entities.ChunkedResumptionToken(set='',
                                             from_='',
                                             until='',
                                             offset='1998-01-01(0)',
                                             count='1000',
                                             metadataPrefix='oai_dc')
     self.assertEqual(token.encode(), ':::1998-01-01(0):1000:oai_dc')
示例#3
0
 def test_non_first_page_detection_on_different_from_year(self):
     token = entities.ChunkedResumptionToken(set='',
                                             from_='1998-01-01',
                                             until='1999-12-31',
                                             offset='1999-01-01(0)',
                                             count='1000',
                                             metadataPrefix='oai_dc')
     self.assertFalse(token.is_first_page())
示例#4
0
 def test_encode_treats_none_as_empty_strings(self):
     token = entities.ChunkedResumptionToken(set='',
                                             from_='1998-01-01',
                                             until='1998-12-31',
                                             offset='1998-01-01(0)',
                                             count=None,
                                             metadataPrefix='oai_dc')
     self.assertEqual(token.encode(),
                      ':1998-01-01:1998-12-31:1998-01-01(0)::oai_dc')
示例#5
0
 def test_encode_turns_integer_to_string(self):
     token = entities.ChunkedResumptionToken(set='',
                                             from_='1998-01-01',
                                             until='1998-12-31',
                                             offset='1998-01-01(0)',
                                             count=1000,
                                             metadataPrefix='oai_dc')
     self.assertEqual(token.encode(),
                      ':1998-01-01:1998-12-31:1998-01-01(0):1000:oai_dc')
示例#6
0
 def test_token_is_encoded_correctly(self):
     token = entities.ChunkedResumptionToken(set='',
                                             from_='1998-01-01',
                                             until='1998-12-31',
                                             offset='1998-01-01(0)',
                                             count='1000',
                                             metadataPrefix='oai_dc')
     self.assertEqual(token.encode(),
                      ':1998-01-01:1998-12-31:1998-01-01(0):1000:oai_dc')
示例#7
0
 def test_decodes_empty_values_to_empty_strings(self):
     token = ':::1998-01-01(0):1000:oai_dc'
     self.assertEqual(
         entities.ChunkedResumptionToken.decode(token),
         entities.ChunkedResumptionToken(set='',
                                         from_='',
                                         until='',
                                         offset='1998-01-01(0)',
                                         count='1000',
                                         metadataPrefix='oai_dc'))
示例#8
0
 def setUp(self):
     self.object = entities.ChunkedResumptionToken()