def verify_ordering(test_class, page, expected_orderings):
 xblocks = page.xblocks
 blocks_checked = set()
 for expected_ordering in expected_orderings:
  for xblock in xblocks:
   parent = expected_ordering.keys()[0]
   if (xblock.name == parent):
    blocks_checked.add(parent)
    children = xblock.children
    expected_length = len(expected_ordering.get(parent))
    test_class.assertEqual(expected_length, len(children), 'Number of children incorrect for group {0}. Expected {1} but got {2}.'.format(parent, expected_length, len(children)))
    for (idx, expected) in enumerate(expected_ordering.get(parent)):
     test_class.assertEqual(expected, children[idx].name)
     blocks_checked.add(expected)
    break
 test_class.assertEqual(len(blocks_checked), len(xblocks))

def verify_ordering ( test_class , page , expected_orderings ) : xblocks = page . xblocks blocks_checked = set ( ) for expected_ordering in expected_orderings : for xblock in xblocks : parent = expected_ordering . keys ( ) [ 0 ] if ( xblock . name == parent ) : blocks_checked . add ( parent ) children = xblock . children expected_length = len ( expected_ordering . get ( parent ) ) test_class . assertEqual ( expected_length , len ( children ) , 'Number of children incorrect for group {0}. Expected {1} but got {2}.' . format ( parent , expected_length , len ( children ) ) ) for ( idx , expected ) in enumerate ( expected_ordering . get ( parent ) ) : test_class . assertEqual ( expected , children [ idx ] . name ) blocks_checked . add ( expected ) break test_class . assertEqual ( len ( blocks_checked ) , len ( xblocks ) )
verifies the expected ordering of xblocks on the page .