s4-test: added test suite for common.py code
[rusty/samba.git] / source4 / scripting / python / samba / tests / common.py
1 #!/usr/bin/env python
2
3 # Unix SMB/CIFS implementation. Tests for common.py routines
4 # Copyright (C) Andrew Tridgell 2011
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 """Tests for samba.common"""
21
22 import samba, os
23 import samba.tests
24 from samba.common import *
25 from samba.samdb import SamDB
26
27
28 class CommonTests(samba.tests.TestCase):
29
30     def test_normalise_int32(self):
31         self.assertEquals('17', normalise_int32(17))
32         self.assertEquals('17', normalise_int32('17'))
33         self.assertEquals('-123', normalise_int32('-123'))
34         self.assertEquals('-1294967296', normalise_int32('3000000000'))
35
36     def test_dsdb_Dn(self):
37         sam = samba.Ldb(url='dntest.ldb')
38         dn1 = dsdb_Dn(sam, "DC=foo,DC=bar")
39         dn2 = dsdb_Dn(sam, "B:8:0000000D:<GUID=b3f0ec29-17f4-452a-b002-963e1909d101>;DC=samba,DC=example,DC=com")
40         self.assertEquals(dn2.binary, "0000000D")
41         self.assertEquals(13, dn2.get_binary_integer())
42         os.unlink('dntest.ldb')