build: Change bin/default/python -> bin/python symlink to bin/default/python_modules
[nivanova/samba-autobuild/.git] / source4 / scripting / python / samba / tests / dcerpc / unix.py
1 # Unix SMB/CIFS implementation.
2 # Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
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.unixinfo."""
19
20
21 from samba.dcerpc import unixinfo
22 from samba.tests import RpcInterfaceTestCase
23
24 class UnixinfoTests(RpcInterfaceTestCase):
25
26     def setUp(self):
27         super(UnixinfoTests, self).setUp()
28         self.conn = unixinfo.unixinfo("ncalrpc:", self.get_loadparm())
29
30     def test_getpwuid_int(self):
31         infos = self.conn.GetPWUid(range(512))
32         self.assertEquals(512, len(infos))
33         self.assertEquals("/bin/false", infos[0].shell)
34         self.assertTrue(isinstance(infos[0].homedir, unicode))
35
36     def test_getpwuid(self):
37         infos = self.conn.GetPWUid(map(long, range(512)))
38         self.assertEquals(512, len(infos))
39         self.assertEquals("/bin/false", infos[0].shell)
40         self.assertTrue(isinstance(infos[0].homedir, unicode))
41
42     def test_gidtosid(self):
43         self.conn.GidToSid(1000L)
44
45     def test_uidtosid(self):
46         self.conn.UidToSid(1000)
47
48     def test_uidtosid_fail(self):
49         self.assertRaises(TypeError, self.conn.UidToSid, "100")