source: trunk/packages/python-afs/afs/tests/test__pts.py @ 2607

Last change on this file since 2607 was 2599, checked in by broder, 15 years ago

Import python-afs.

Debathena should eventually be importing PyAFS for
<http://debathena.mit.edu/trac/ticket/395>, so hopefully this is only
temporary.

File size: 1.3 KB
RevLine 
[2599]1import os
2from afs._pts import PTS
3import nose
4
5def get_this_cell():
6    # Feel free to add more places ThisCell might show up
7    to_try = ['/private/var/db/openafs/etc/ThisCell',
8              '/etc/openafs/ThisCell',
9              '/usr/vice/etc/ThisCell']
10    for f in to_try:
11        if os.path.isfile(f):
12            return open(f).read().strip()
13
14def test_init_home_cell():
15    p = PTS()
16    assert p.cell == get_this_cell(), "PTS doesn't initialize to ThisCell when none specified."
17
18def test_init_other_cell():
19    cell = 'zone.mit.edu'
20    p = PTS('zone.mit.edu')
21    assert p.cell == cell, "PTS doesn't initialize to provided cell."
22
23def test_user_name_to_id():
24    p = PTS()
25    name = 'broder'
26    id = p._NameToId(name)
27    assert id == 41803, "PTS can't convert user name to ID."
28    assert p._IdToName(id) == name, "PTS can't convert user ID to name."
29
30def test_group_name_to_id():
31    p = PTS()
32    name = 'system:administrators'
33    id = p._NameToId(name)
34    assert id == -204, "PTS can't convert group name to ID."
35    assert p._IdToName(id) == name, "PTS can't convert group ID to name."
36
37def test_name_or_id():
38    p = PTS()
39    name = 'system:administrators'
40    id = -204
41    assert p._NameOrId(name) == id, "PTS._NameOrId can't identify name."
42    assert p._NameOrId(id) == id, "PTS._NameOrId can't identify ID."
43
44if __name__ == '__main__':
45    nose.main()
Note: See TracBrowser for help on using the repository browser.