blob: 74ceeea910d99b6ed9f91903eb480dc3d7b5d559 [file] [log] [blame]
Barry Warsaw04f357c2002-07-23 19:04:11 +00001from test.test_support import verbose, TestFailed, TestSkipped
Barry Warsaw3236b331996-12-11 01:01:38 +00002import nis
3
Barry Warsaw5e056bb1996-12-23 23:39:42 +00004print 'nis.maps()'
Barry Warsaw4c4d5ce1997-05-15 18:27:49 +00005try:
Barry Warsaw4c4d5ce1997-05-15 18:27:49 +00006 maps = nis.maps()
7except nis.error, msg:
Barry Warsaw72588741999-01-28 04:54:33 +00008 # NIS is probably not active, so this test isn't useful
9 if verbose:
10 raise TestFailed, msg
11 # only do this if running under the regression suite
Thomas Woutersb9fa0a82000-08-04 13:34:43 +000012 raise TestSkipped, msg
Barry Warsaw4c4d5ce1997-05-15 18:27:49 +000013
Martin v. Löwis920fa6a2006-10-22 13:46:23 +000014try:
15 # On some systems, this map is only accessible to the
16 # super user
17 maps.remove("passwd.adjunct.byname")
18except ValueError:
19 pass
20
Guido van Rossum2b6c2fa1996-12-11 16:28:30 +000021done = 0
22for nismap in maps:
23 if verbose:
Guido van Rossum41360a41998-03-26 19:42:58 +000024 print nismap
Guido van Rossum2b6c2fa1996-12-11 16:28:30 +000025 mapping = nis.cat(nismap)
26 for k, v in mapping.items():
Guido van Rossum41360a41998-03-26 19:42:58 +000027 if verbose:
28 print ' ', k, v
29 if not k:
30 continue
Fred Drake132dce22000-12-12 23:11:42 +000031 if nis.match(k, nismap) != v:
Guido van Rossum41360a41998-03-26 19:42:58 +000032 print "NIS match failed for key `%s' in map `%s'" % (k, nismap)
33 else:
34 # just test the one key, otherwise this test could take a
35 # very long time
36 done = 1
37 break
Guido van Rossum2b6c2fa1996-12-11 16:28:30 +000038 if done:
Guido van Rossum41360a41998-03-26 19:42:58 +000039 break