blob: e1670d16e544531c2f8eda197b7ceb1423297cc8 [file] [log] [blame]
Fredrik Lundhf7850422001-01-17 21:51:36 +00001from 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
Guido van Rossum2b6c2fa1996-12-11 16:28:30 +000014done = 0
15for nismap in maps:
16 if verbose:
Guido van Rossum41360a41998-03-26 19:42:58 +000017 print nismap
Guido van Rossum2b6c2fa1996-12-11 16:28:30 +000018 mapping = nis.cat(nismap)
19 for k, v in mapping.items():
Guido van Rossum41360a41998-03-26 19:42:58 +000020 if verbose:
21 print ' ', k, v
22 if not k:
23 continue
Fred Drake132dce22000-12-12 23:11:42 +000024 if nis.match(k, nismap) != v:
Guido van Rossum41360a41998-03-26 19:42:58 +000025 print "NIS match failed for key `%s' in map `%s'" % (k, nismap)
26 else:
27 # just test the one key, otherwise this test could take a
28 # very long time
29 done = 1
30 break
Guido van Rossum2b6c2fa1996-12-11 16:28:30 +000031 if done:
Guido van Rossum41360a41998-03-26 19:42:58 +000032 break