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'))
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')
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())
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')
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')
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')
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'))
def setUp(self): self.object = entities.ChunkedResumptionToken()