def test_uuid4_args_unsupported(self): self.assertRaises(NotImplementedError, lambda: libuuid.uuid1(42)) self.assertRaises(NotImplementedError, lambda: libuuid.uuid1(42, 42)) self.assertRaises(NotImplementedError, lambda: libuuid.uuid1(node=42)) self.assertRaises(NotImplementedError, lambda: libuuid.uuid1(clock_seq=42)) self.assertRaises(NotImplementedError, lambda: libuuid.uuid1(node=42, clock_seq=42))
def test_basic_sanity_uuid1(self): buf = set() clocks = [] for _ in xrange(1000): u = libuuid.uuid1() clocks.append(u.time) self.assert_(u.bytes not in buf) buf.add(u.bytes) self.assertEquals(clocks, sorted(clocks), "Timestamps increment") t = (time.time() * 1e7) + 0x01b21dd213814000L # RFC 4122 timestamp diff = abs(t - clocks[-1]) self.assert_(diff < 10000, "Timestamp reasonable")
def test_basic_sanity_uuid1(self): buf = set() clocks = [] for _ in range(1000): u = libuuid.uuid1() clocks.append(u.time) self.assert_(u.bytes not in buf) buf.add(u.bytes) self.assertEquals(clocks, sorted(clocks), "Timestamps increment") t = (time.time() * 1e7) + 0x01b21dd213814000 # RFC 4122 timestamp diff = abs(t - clocks[-1]) self.assert_(diff < 10000, "Timestamp reasonable")
def request(self): cn = str(libuuid.uuid1()) # cn = '%s_%s' % (self.tid, self.i) sn = str(self.tid) dn = template_dn % (cn) entry = list(template_entry) entry.append(('cn', [cn])) entry.append(('sn', [sn])) self.i += 1 try: (rc, msg) = self.ldap.add_s(dn, entry) if rc == 105: return True else: print "error: " + str(rc) return False except ldap.LDAPError as le: print le.message except Exception as e: print traceback.format_exc() return False
def _get_uuid_path(): # Make a pairtree-like path from a uuid # Wonder if this should be time.time() plus some random check chars, # just to make it shorter _id = uuid.uuid1().hex return path.sep.join([_id[i:i+2] for i in range(0, len(_id), 2)])
def test_uuid1(self): u = libuuid.uuid1() u2 = uuid.UUID(bytes=u.bytes) self.assertEqual(u.bytes, u2.bytes)
def _runsome(): for _ in xrange(200): q.put(libuuid.uuid4().hex) q.put(libuuid.uuid1().hex)
def _runsome(): for _ in range(200): q.put(libuuid.uuid4().hex) q.put(libuuid.uuid1().hex)