Commit 27dcf35f authored by Paul Selkirk's avatar Paul Selkirk
Browse files

[2908] iterate directly on ZoneTableAccessor

parent 827f143e
......@@ -173,7 +173,7 @@ class ClientListTest(unittest.TestCase):
# first datasrc - empty zone table
table = self.clist.get_zone_table_accessor(None, True)
self.assertIsNotNone(table)
iterator = table.get_iterator()
iterator = iter(table)
self.assertIsNotNone(iterator)
self.assertEqual(0, len(list(iterator)))
......@@ -194,16 +194,13 @@ class ClientListTest(unittest.TestCase):
# first datasrc
table = self.clist.get_zone_table_accessor(None, True)
self.assertIsNotNone(table)
iterator = table.get_iterator()
self.assertIsNotNone(iterator)
zonelist = list(iterator)
zonelist = list(table)
self.assertEqual(1, len(zonelist))
self.assertEqual(zonelist[0][1], isc.dns.Name("example.org"))
# named datasrc
table = self.clist.get_zone_table_accessor("MasterFiles", True)
iterator = table.get_iterator()
self.assertEqual(zonelist, list(iterator))
self.assertEqual(zonelist, list(table))
# longer zone list for non-trivial iteration
self.clist.configure('''[{
......@@ -217,8 +214,7 @@ class ClientListTest(unittest.TestCase):
},
"cache-enable": true
}]''', True)
zonelist = list(self.clist.get_zone_table_accessor(None, True).
get_iterator())
zonelist = list(self.clist.get_zone_table_accessor(None, True))
self.assertEqual(5, len(zonelist))
self.assertTrue((0, isc.dns.Name("example.net.")) in zonelist)
......@@ -230,7 +226,7 @@ class ClientListTest(unittest.TestCase):
isc.dns.Name("example.biz"),
isc.dns.Name("example.edu")]
table = self.clist.get_zone_table_accessor("MasterFiles", True)
for index, zone in table.get_iterator():
for index, zone in table:
self.assertTrue(zone in zonelist)
zonelist.remove(zone)
self.assertEqual(0, len(zonelist))
......
......@@ -67,7 +67,7 @@ ZoneTableAccessor_destroy(PyObject* po_self) {
}
PyObject*
ZoneTableAccessor_getIterator(PyObject* po_self, PyObject* args) {
ZoneTableAccessor_iter(PyObject* po_self) {
s_ZoneTableAccessor* const self =
static_cast<s_ZoneTableAccessor*>(po_self);
try {
......@@ -90,12 +90,6 @@ ZoneTableAccessor_getIterator(PyObject* po_self, PyObject* args) {
// 3. Argument type
// 4. Documentation
PyMethodDef ZoneTableAccessor_methods[] = {
{ "get_iterator",
ZoneTableAccessor_getIterator, METH_NOARGS,
"get_iterator() -> isc.datasrc.ZoneTableIterator\n\
\n\
Return a zone table iterator.\n\
\n" },
{ NULL, NULL, 0, NULL }
};
......@@ -139,9 +133,9 @@ PyTypeObject zonetableaccessor_type = {
NULL, // tp_clear
NULL, // tp_richcompare
0, // tp_weaklistoffset
NULL, // tp_iter
ZoneTableAccessor_iter, // tp_iter
NULL, // tp_iternext
ZoneTableAccessor_methods, // tp_methods
ZoneTableAccessor_methods, // tp_methods
NULL, // tp_members
NULL, // tp_getset
NULL, // tp_base
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment