Beispiel #1
0
    def test_length(self):
        subject = SaltedTimeIDFactory()
        id = subject.create_id()
        self.assertEqual(10, len(id))

        sub2 = SaltedTimeIDFactory(salt_chars=5)
        id = sub2.create_id()
        self.assertEqual(12, len(id))
Beispiel #2
0
 def __init__(self, pools, representation=None):
     self._pool = pools
     if representation:
         self._representation = representation
     else:
         self._id_factory = SaltedTimeIDFactory()
         self._representation = IonSerializerDictionaryRepresentation(id_factory=self._id_factory)
Beispiel #3
0
 def test_change_salt(self):
     # use unusually large salt to make it
     # nearly impossible 2 random salts will be equal
     subject = SaltedTimeIDFactory(salt_chars=10)
     id1 = subject.create_id()
     id2 = subject.replace_duplicate()
     self.assertTrue(id1[-10:]!=id2[-10:])
Beispiel #4
0
 def test_increasing(self):
     subject = SaltedTimeIDFactory()
     id1 = subject.create_id()
     for n in xrange(20):
         id2 = subject.create_id()
         self.assertTrue(id2>id1, msg='%s v %s'%(id1,id2))
         id1=id2
Beispiel #5
0
 def setUp(self):
     self.subject = IonSerializerDictionaryRepresentation(id_factory=SaltedTimeIDFactory())