source: trunk/packages/xen-common/xen-common/tools/python/xen/xend/tests/test_uuid.py @ 34

Last change on this file since 34 was 34, checked in by hartmans, 17 years ago

Add xen and xen-common

File size: 792 bytes
Line 
1import unittest
2
3from xen.xend import uuid
4
5
6class test_uuid(unittest.TestCase):
7
8    def testStringRoundtrip(self):
9        def t(inp):
10            self.assertEqual(uuid.fromString(uuid.toString(inp)), inp)
11
12        t(uuid.create())
13        t(uuid.create())
14        t(uuid.create())
15        t(uuid.create())
16        t(uuid.create())
17
18
19    def testToFromString(self):
20        def t(inp, expected):
21            self.assertEqual(uuid.toString(inp), expected)
22            self.assertEqual(uuid.fromString(expected), inp)
23
24        t([0 for _ in range(0, 16)], "00000000-0000-0000-0000-000000000000")
25        t([185, 158, 125, 206, 250, 178, 125, 57, 2, 6, 162, 74, 178, 236,
26           196, 5], "b99e7dce-fab2-7d39-0206-a24ab2ecc405")
27
28
29def test_suite():
30    return unittest.makeSuite(test_uuid)
Note: See TracBrowser for help on using the repository browser.