From d6f8af2738d1b43aae5073186c8de131dfe48ceb Mon Sep 17 00:00:00 2001 From: Evan Broder Date: Thu, 19 Mar 2009 12:55:34 -0400 Subject: [PATCH] Add tests for PTS._NameToId, PTS._IdToName, and PTS._NameOrId. Signed-off-by: Evan Broder --- afs/tests/test__pts.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/afs/tests/test__pts.py b/afs/tests/test__pts.py index d52a066..64297b1 100644 --- a/afs/tests/test__pts.py +++ b/afs/tests/test__pts.py @@ -20,5 +20,26 @@ def test_init_other_cell(): p = PTS('zone.mit.edu') assert p.cell == cell, "PTS doesn't initialize to provided cell." +def test_user_name_to_id(): + p = PTS() + name = 'broder' + id = p._NameToId(name) + assert id == 41803, "PTS can't convert user name to ID." + assert p._IdToName(id) == name, "PTS can't convert user ID to name." + +def test_group_name_to_id(): + p = PTS() + name = 'system:administrators' + id = p._NameToId(name) + assert id == -204, "PTS can't convert group name to ID." + assert p._IdToName(id) == name, "PTS can't convert group ID to name." + +def test_name_or_id(): + p = PTS() + name = 'system:administrators' + id = -204 + assert p._NameOrId(name) == id, "PTS._NameOrId can't identify name." + assert p._NameOrId(id) == id, "PTS._NameOrId can't identify ID." + if __name__ == '__main__': nose.main() -- 1.7.9.5