Move python modules from source4/scripting/python/ to python/.
[nivanova/samba-autobuild/.git] / python / samba / tests / dcerpc / misc.py
1 # Unix SMB/CIFS implementation.
2 # Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 #
17
18 """Tests for samba.dcerpc.misc."""
19
20 from samba.dcerpc import misc
21 import samba.tests
22
23 text1 = "76f53846-a7c2-476a-ae2c-20e2b80d7b34"
24 text2 = "344edffa-330a-4b39-b96e-2c34da52e8b1"
25
26 class GUIDTests(samba.tests.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 class PolicyHandleTests(samba.tests.TestCase):
49
50     def test_init(self):
51         x = misc.policy_handle(text1, 1)
52         self.assertEquals(1, x.handle_type)
53         self.assertEquals(text1, str(x.uuid))
54
55     def test_repr(self):
56         x = misc.policy_handle(text1, 42)
57         self.assertEquals("policy_handle(%d, '%s')" % (42, text1), repr(x))
58
59     def test_str(self):
60         x = misc.policy_handle(text1, 42)
61         self.assertEquals("%d, %s" % (42, text1), str(x))
62