'Test filtering of the tree with leafonly=True'

def testFilteringLeafOnly(self):

    uids = self.uids
    assertEqual = self.assertEqual
    assertTrue = self.assertTrue
    h = S3Hierarchy('test_lhierarchy', filter=(FS('type') == 'D'), leafonly=True)
    nodes = h.nodes
    expected = ['LHIERARCHY2', 'LHIERARCHY2-1', 'LHIERARCHY2-1-2']
    assertEqual(len(nodes), len(expected))
    assertTrue(all(((uids[uid] in nodes) for uid in expected)))
    for node in nodes.values():
        assertTrue(all(((child_id in nodes) for child_id in node['s'])))
        parent_id = node['p']
        if parent_id:
            assertTrue((parent_id in nodes))
