ldb: make ldb module programming less error prone
[ira/wip.git] / source4 / scripting / python / samba / tests / misc.py
1 #!/usr/bin/python
2
3 # Unix SMB/CIFS implementation.
4 # Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
5 #   
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10 #   
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #   
16 # You should have received a copy of the GNU General Public License
17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 #
19
20 import unittest
21 from samba.dcerpc import misc
22
23 text1 = "76f53846-a7c2-476a-ae2c-20e2b80d7b34"
24 text2 = "344edffa-330a-4b39-b96e-2c34da52e8b1"
25
26 class GUIDTests(unittest.TestCase):
27
28     def test_str(self):
29         guid = misc.GUID(text1)
30         self.assertEquals(text1, str(guid))
31
32     def test_repr(self):
33         guid = misc.GUID(text1)
34         self.assertEquals("GUID('%s')" % text1, repr(guid))
35
36     def test_compare_different(self):
37         guid1 = misc.GUID(text1)
38         guid2 = misc.GUID(text2)
39         self.assertTrue(cmp(guid1, guid2) > 0)
40
41     def test_compare_same(self):
42         guid1 = misc.GUID(text1)
43         guid2 = misc.GUID(text1)
44         self.assertEquals(0, cmp(guid1, guid2))
45         self.assertEquals(guid1, guid2)
46
47
48          
49         
50 class PolicyHandleTests(unittest.TestCase):
51
52     def test_init(self):
53         x = misc.policy_handle(text1, 1)
54         self.assertEquals(1, x.handle_type)
55         self.assertEquals(text1, str(x.uuid))
56
57     def test_repr(self):
58         x = misc.policy_handle(text1, 42)
59         self.assertEquals("policy_handle(%d, '%s')" % (42, text1), repr(x))
60
61     def test_str(self):
62         x = misc.policy_handle(text1, 42)
63         self.assertEquals("%d, %s" % (42, text1), str(x))
64