示例#1
0
 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))
示例#2
0
 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")
示例#3
0
 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")
示例#4
0
文件: add.py 项目: hamano/lb
    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
示例#5
0
 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
示例#6
0
	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)])
示例#7
0
 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))
示例#8
0
 def test_uuid1(self):
     u = libuuid.uuid1()
     u2 = uuid.UUID(bytes=u.bytes)
     self.assertEqual(u.bytes, u2.bytes)
示例#9
0
 def _runsome():
     for _ in xrange(200):
         q.put(libuuid.uuid4().hex)
         q.put(libuuid.uuid1().hex)
示例#10
0
 def test_uuid1(self):
     u = libuuid.uuid1()
     u2 = uuid.UUID(bytes=u.bytes)
     self.assertEqual(u.bytes, u2.bytes)
示例#11
0
 def _runsome():
     for _ in range(200):
         q.put(libuuid.uuid4().hex)
         q.put(libuuid.uuid1().hex)