예제 #1
0
 def test_simpleflake_parts_random(self):
     random_bits = random.getrandbits(5)
     flake = sf.simpleflake(random_bits=random_bits)
     rand_result = sf.extract_bits(flake,
                                   sf.SIMPLEFLAKE_RANDOM_SHIFT,
                                   sf.SIMPLEFLAKE_RANDOM_LENGTH)
     self.assertEquals(random_bits, rand_result)
예제 #2
0
 def test_simpleflake_parts_random(self):
     random_bits = random.getrandbits(5)
     flake = sf.simpleflake(random_bits=random_bits)
     rand_result = sf.extract_bits(flake,
                                   sf.SIMPLEFLAKE_RANDOM_SHIFT,
                                   sf.SIMPLEFLAKE_RANDOM_LENGTH)
     self.assertEquals(random_bits, rand_result)
예제 #3
0
파일: test.py 프로젝트: apiguy/simpleflake
 def test_simpleflake_parts_timestamp(self):
     coolstamp = SIMPLEFLAKE_EPOCH + 1234321.0
     epoch_flake = simpleflake(timestamp=coolstamp)
     timestamp = extract_bits(epoch_flake,
                              SIMPLEFLAKE_TIMESTAMP_SHIFT,
                              SIMPLEFLAKE_TIMESTAMP_LENGTH)
     self.assertEquals(coolstamp, (timestamp / 1000.0) + SIMPLEFLAKE_EPOCH)
예제 #4
0
 def test_simpleflake_parts_timestamp(self):
     coolstamp = sf.SIMPLEFLAKE_EPOCH + 1234321.0
     epoch_flake = sf.simpleflake(timestamp=coolstamp)
     timestamp = sf.extract_bits(epoch_flake,
                                 sf.SIMPLEFLAKE_TIMESTAMP_SHIFT,
                                 sf.SIMPLEFLAKE_TIMESTAMP_LENGTH)
     self.assertEquals(coolstamp,
                       (timestamp / 1000.0) + sf.SIMPLEFLAKE_EPOCH)