Exemple #1
0
 def test_max_int(self):
     encoded = short_id.encode(short_id.MAX_ID)
     if short_id.DATASTORE_BITS == 128:
         self.assertEquals(encoded, 'F=_g')
     elif short_id.DATASTORE_BITS == 64:
         self.assertEquals(encoded, '7=_A')
     else:
         self.fail("number of bits in a datastore id is not an expected value (64 or 128")
Exemple #2
0
 def test_max_int(self):
     encoded = short_id.encode(short_id.MAX_ID)
     if short_id.DATASTORE_BITS == 128:
         self.assertEquals(encoded, 'F=_g')
     elif short_id.DATASTORE_BITS == 64:
         self.assertEquals(encoded, '7=_A')
     else:
         self.fail(
             "number of bits in a datastore id is not an expected value (64 or 128"
         )
Exemple #3
0
 def test_reject_number_too_long(self):
     x = short_id.encode(short_id.MAX_ID) + '0'
     with self.assertRaises(DecodeError) as cm:
         short_id.decode(x)
     e = cm.exception
     self.assertEqual(e.code, DecodeError.OVERFLOW)
Exemple #4
0
 def test_decode_max_int(self):
     x = short_id.decode(short_id.encode(short_id.MAX_ID))
     self.assertEquals(short_id.MAX_ID, x)
Exemple #5
0
 def test__zero(self):
     x = short_id.decode(short_id.encode(0))
     self.assertEquals(0, x)
     self.assertEqual(int, x.__class__)
Exemple #6
0
 def test_encode_max_numeral(self):
     s = short_id.encode(short_id.NUMERAL_RADIX - 1)
     self.assertEquals(s, short_id.NUMERAL[-1])
Exemple #7
0
 def test_encode_zero(self):
     self.assertEquals(short_id.encode(0), '0')
Exemple #8
0
 def test_reject_number_too_long(self):
     x = short_id.encode(short_id.MAX_ID) + '0'
     with self.assertRaises(DecodeError) as cm:
         short_id.decode(x)
     e = cm.exception
     self.assertEqual(e.code, DecodeError.OVERFLOW)
Exemple #9
0
 def test_decode_max_int(self):
     x = short_id.decode(short_id.encode(short_id.MAX_ID))
     self.assertEquals(short_id.MAX_ID, x)
Exemple #10
0
 def test__zero(self):
     x = short_id.decode(short_id.encode(0))
     self.assertEquals(0, x)
     self.assertEqual(int, x.__class__)
Exemple #11
0
 def test_encode_max_numeral(self):
     s = short_id.encode(short_id.NUMERAL_RADIX - 1)
     self.assertEquals(s, short_id.NUMERAL[-1])
Exemple #12
0
 def test_encode_zero(self):
     self.assertEquals(short_id.encode(0), '0')