xref: /netbsd-src/external/bsd/unbound/dist/testdata/pylib.tdir/pylib.lookup.py (revision bdc22b2e01993381dcefeff2bc9b56ca75a4235c)
1#!/usr/bin/env python
2'''
3Test for unbound lookup.
4BSD licensed.
5'''
6import unbound
7
8ctx = unbound.ub_ctx()
9status = ctx.config("ub.conf")
10if status != 0:
11	print "read config failed ", status
12	exit(1)
13
14print "config created"
15
16status, result = ctx.resolve("www.example.com", unbound.RR_TYPE_A, unbound.RR_CLASS_IN);
17if status == 0 and result.havedata:
18	print "Result: ", result.data.address_list
19else:
20	print "Failed ", status, " and data ", result
21
22ctx = None
23
24exit(0)
25